Tag Archives: angularjs online course

AngularJs Encode URL


AngularJs Encode URL Example : We can use the javascript inbuilt function encodeURIComponent(string), encodeURI(string) or escape(string) to encode the url string. Here in this tutorial we are going to explain how you can encode url string with example and online demo.


AngularJs Encode URL Parameters | String | JavaScript | Example

Let us create a simple example to use the function encodeURIComponent(string) to encode the url parameters.

AngularJs Encode URL Parameters: Example

 
 

  

URL1 = {{url1}}
URL2 = {{url2}}

Try it Β»

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

AngularJs Encode URL

Note:

Keep in mind the difference between the three functions before using them.

  • escape(): This will not encode: @*/+
  • encodeURI(): This will not encode: ~!@#$&*()=:/,;?+’
  • encodeURIComponent(): This will not encode: ~!*()’

Angularjs radio button checked


Angularjs radio button checked : There are many ways to set radio button checked on button click. You can use ng-checked to check a radio button in AngularJs. Here in this tutorial we are going to explain how you can set radio button checked in AngularJs. You can also use our online tool to run and edit the code.


Angularjs radio button checked on Button Click Example

You can set radio button checked on button click as below-

JavaScript Part –

JavaScript Part Contains the following script –

Angularjs radio button checked on Button Click : JavaScript

 

Html Part-

Html Part Contains the following html –

Angularjs radio button checked on Button Click:



Complete Example-

Now let us combine both javascript and html parts. Here is the complete example –

How to set radio checked on Button Click Example:

 
 

  


Try it Β»

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

Angularjs radio button checked

Angularjs set checkbox checked


Angularjs set checkbox checked : There are many ways to set checkbox checked on button click. You can use ng-checked to check a checkbox in AngularJs. Here in this tutorial we are going to explain how you can set checkbox checked in AngularJs. You can also use our online tool to run and edit the code.


Angularjs set checkbox checked on Button Click Example

You can set checkbox checked on button click as below-

JavaScript Part –

JavaScript Part Contains the following script –

Angularjs set checkbox checked on Button Click : JavaScript

 

Html Part-

Html Part Contains the following html –

Angularjs set checkbox checked on Button Click:



Complete Example-

Now let us combine both javascript and html parts. Here is the complete example –

How to set checkbox checked on Button Click Example:

 
 

  


Try it Β»

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

Angularjs set checkbox checked

AngularJs Check if Reference is Array


AngularJs Check if Reference is Array – You can use the function angular.isArray() to chack whether a variable is array or not in AngularJs. Here in this tutorial we are going to explain how you can use angular.isArray() in AngularJs. You can use our online editor to edit and run the code online.


AngularJs Check if Reference is Array | Check if Variable is Array | Example

Syntax

Syntax for angular.isArray() function is –

Angularjs Check if Variable is Array | Syntax :

angular.isArray(var);

Agruments

  • var – Value to be checked.

Return

This will return true if variable or string is array else false.

Example

Let us create a simple example to check if given string is array-

AngularJs Check if String is Array:

 
 

  


Try it Β»

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

AngularJs Check if Reference is Array

Get element by class name in AngularJs


Get element by class name in AngularJs : It is very common to deal with class and id selector in AngularJs. You can use AngularJs jQuery lite to get all elements by class name. Here in this tutorial we are going to explain how to use jQlite to get element by class name. You can also use our online tool to run and edit the code.


How to Get element by class name in AngularJs?

You can use jQlite angular.element() to get the element by class name. Let us go step by step.

JavaScript Part –

JavaScript Part Contains the following script –

Get element by class name in AngularJs : JavaScript

  

Html Part-

Html Part Contains the following html –

Get element by class name in AngularJs Example:

AngularJs Is Cool!

This is test paragraph....

Complete Example-

Now let us combine both javascript and html parts. Here is the complete example –

Get element by class name in AngularJs:

 
 




 
 

  

AngularJs Is Cool!

This is test paragraph....

Try it Β»

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

Get element by class name in AngularJs

Update array item in AngularJs


Update array item in AngularJs : It is very simple to update an item of array in AngularJs. Here in this tutorial we are going to explain how to update an item in AngularJs Array. You can also use our online tool to run and edit the code.


How to update array item in AngularJs?

To update an array item in AngularJs we first need to find the item index then assign new value using the index. Here is an example of updating an item in array.

JavaScript Part –

JavaScript Part Contains the following script –

Update array item in AngularJs: JavaScript

 

Html Part-

Html Part Contains the following html –

AngularJs update Object or Array item Example:

Update b in array = {{myArray}}

Complete Example-

Now let us combine both javascript and html parts. Here is the complete example –

AngularJs Delete Item or Object From Array:

 
 




 
 

  

Update b in array = {{myArray}}

Try it Β»

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

If you click on the β€œUpdate b” button it will update b by value 100.
Update array item in AngularJs

String to number Angularjs


String to number Angularjs – You can use parseInt to convert string to integer . Here in this tutorial we are going to explain how you can use parseInt() to convert the string into Integer in AngularJs. You can use our online demo try and edit the code online.


Convert String to number Angularjs | String To Int

You can use split() method to split string into array. Here is full example –

Convert String to Int Angularjs Example:

 
 

  

Before Conversion a + b = {{a + b}}
After Converting to Int a1 + b1 = {{a1 + b1}}

Try it Β»

In the above example we have created a simple example to add to numbers after converting into int in AngularJs.

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

String to number Angularjs

AngularJs split string


AngularJs split string – There are many ways to split string . Here in this tutorial we are going to explain how you can use split() method to split the string in AngularJs. You can use our online demo try and edit the code online.


AngularJs split String to Array | Example

You can use split() method to split string into array. Here is full example –

AngularJs split String to Array | Comma Separated string Example:

 
 

  
String[0] = {{exampleString.split(',')[0]}}
String[1] = {{exampleString.split(',')[1]}}
String[2] = {{exampleString.split(',')[2]}}

Try it Β»

In the above example we have created a simple example to split the string in AngularJs.

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

AngularJs split String to Array | Example

Replace String in AngularJs


Replace String in AngularJs- It is very simple to replace a string in AngularJs. You can use replace method same as we use in JavaScript. Here in this tutorial we are going to explain how you can use replace() method to replace string in AngularJs. You can use our online demo try and edit the code online.


How to Replace String in AngularJs | Example

You can use replace() method to replace string. Here is full example –

How to Replace String in AngularJs | Example:

 
 

  
Enter a value and click "Replace" Button to replace the - "World".


String = {{exampleString}}

Try it Β»

In the above example we have created a simple example to replace the string from string in AngularJs.

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

How to Replace String in AngularJs | Example