Tag Archives: angularjs online course

AngularJs ng-click stopPropagation


AngularJs ng-click stopPropagation : Sometimes we need to stopPropagation of ng-click event, It is very simple to stop propagation in AngularJs. Here in this tutorial we are going to explain how you can stop Propagation in AngularJs. You can also use our online editor to edit and run the code online.


AngularJs ng-click stopPropagation Example

You can use $event.stopPropagation() to stop propagation in AngularJs. Let us create an example of it-

AngularJs ng-click stopPropagation Example:

 
 

  

Result = {{result}}

Try it »

In the above example we have used $event object which is used to stopPropagation with $event.stopPropagation() so make sure to pass $event in ng-click function.

If you run the above example it will produce output something like this –

AngularJs ng-click stopPropagation Example

AngularJs ng-include


AngularJs ng-include: You can include another html file using ng-include directive. We sometimes need to include Html content from another html file so in that case we can use this directive. Here in this tutorial we are going to explain how you can use this directive to include another html file in AngularJs. You can also use our online editor to edit and run the code online.


AngularJs ng-include Example

Let us create a simple example to include the Another Html-

AngularJs ng-include Example:

In the above example we have included another html template in the div.

Note : To include template you have to wrap template by double quotes and single quotes as – ng-include=”‘anotherpage.html'” .

Learn More

Let us have some more example about the ng-include.


Include AngularJs Code : Access JavaScript

You can directly access the AngularJs JavaScript inside the included template simply as below –

AngularJs ng-include Example:

 
 

  

In the above example we have two scope variables – $scope.myHeading and $scope.myTitle. You can access these scope variables in included template simply as below –

anotherpage.html Template

anotherpage.Html Page contains the following html, you can access the scope variables as-

AngularJs Access JavaScript Part:

Another Template

{{myHeading}}

{{myTitle}}

ng-include in Angularjs not working

We sometimes face issue regarding the ng-include not working. So make sure you have kept following things in mind –

  • 1. No blank spaces in template path (ng-include=”‘anotherpage.html'”).
  • 2. Remember to use single quotation in double quotation for another page path(ng-include=”‘anotherpage.html'”).

Concat string in AngularJs


Concat string in AngularJs -There are many ways to concat two strings, You can use JavaScript concat() method to concat two or more than two strings in AngularJs. Here in this tutorial we are going to explain how you can join two or more than two strings in angularjs. You can also use our online editor to edit and run the code online.


How to Concat string in AngularJs | Join Strings Example

Let us go step by step to create an example to join strings in AngularJs using JavaScript Concat() method-

JavaScript Part

JavaScript Part Contains the following part as below –

Concat string in AngularJs :

 

Html Part

Html Part contains the following html as below –

Angularjs Join Strings example:


Result = {{result}}

Complete Part

Now let us combine Html and JavaScript Together to create full example like this –

Angularjs Join Strings example

 
 

  

Result = {{result}}

Try it »

If you run the above example it will produce output something like this –

Concat string in AngularJs

AngularJs Break Foreach Loop


AngularJs Break Foreach Loop : Sometimes while working with Angularjs Foreach loop we need to break loop, there is no direct method to add break in Angular foreach loop. Here in this tutorial we are going to explain how you can use do this in foreach loop. You can also use our online editor to edit and run the code online.


AngularJs Break Foreach Loop Example

There is no break statement in Angular foreach loop, still you can do this something like this –

AngularJs Break Foreach Loop Example:

 
 

  
Result = {{html}}

Try it »

If you run the above example it will produce output something like this –

AngularJs Break Foreach Loop Example

AngularJs Insert HTML into View


AngularJs Insert HTML into View : Sometimes we need to insert HTML into view in AngularJs. There are many ways to do this, here in this tutorial we are going to do this using ng-bind-html. You can also use our online editor to edit and run the code online.


AngularJs Insert HTML into View Example

Let us create a simple example to insert HTML into view using ng-bind-html-

AngularJs Insert HTML into Into View Example:

 
 

  

Try it »

Thus you can easily add html to the view using ng-bind-html directive. If you run the above example it will produce the output something like this –

AngularJs Insert HTML into View Example

AngularJs Check All Uncheck All


AngularJs Check All Uncheck All : Sometimes we need functionality to check all and uncheck all checkboxes. Here in this tutorial we are going to explain how you can create this functionality in AnagularJs. You can also use our online editor to edit and run demo.


AngularJs Check All Uncheck All | Select All | Unselect All Example

Unlike jQuery you don’t need to put extra effort to check/uncheck all checkboxes in AngularJs, It is very easy and simple. Here is a simple example for check and uncheck all functionality. –

AngularJs Check All Uncheck All | Example:

 
 

  
Select All Items
{{item.Name}}

Try it »

If you run the above example it will produce output something like this –

AngularJs Check All Uncheck All

AngularJs add item to Array


AngularJs add item to Array- It is very simple to push a value in AngularJs Array . push() method is used to add(push) an element in AngularJs array. Here in this tutorial we are going to explain how you can use push() to insert an element in AngularJs Array. You can use our online demo try and edit the code online.


AngularJs add item to Array | Example

You can use push() method to add an element in an array. Here is full example –

AngularJs add item to Array | Example:

 
 

  
Enter a value and click "Push" Button to insert in array.

Array = {{exampleArray}}

Try it »

In the above example we have created a simple example to add elements in array in AngularJs.

If you run the above example it will produce the output something like this –

AngularJs add item to Array

Angular disable button


Angular disable button On Click – Sometimes we need to disable buttons,links on click event. It is very simple to disable a button in AngularJs. You can use ng-disabled to disable the button, link in AngularJs. Here in this tutorial we are going to explain how you can use ng-disabled to enable and disable button in AngularJs. You can also use our online demo to edit and run the code online.


Angular disable button On Click

Here is a simple example to disable the button in AngularJs-

Angular disable button On Click Example:

 
 

  

Try it »

The above example will disable the button if user clicks on the button. If you run the above example it will produce output something like this-

Angular disable button On Click Example

AngularJs Add Form Fields Dynamically


AngularJs Add Form Fields Dynamically- It is very easy to add the form fields dynamically sometimes we need some form fields to add dynamically. Here in this tutorial we are going to explain how you can create functionality to add some dynamic fields. You can also use our online editor to edit and try the code online.


AngularJs Add Form Fields Dynamically

Let us go step by step to create the dynamic form fields-

Html Part

Html part contains the following part-

AngularJs Add Form Fields Dynamically Example:

Register Form

Name
Email
Phone {{$index+1}}
Qualification {{$index+1}}
Submit

JavaScript Part

JavaScript Part Contains the following parts –

AngularJs Add Form Fields Dynamically Example:


Try it »

If you run the above example it will produce the output something like this –

AngularJs Add Form Fields Dynamically