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.
If you run the above example it will produce output something like this β
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 β
If you run the above example it will produce output something like this β
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 β
If you run the above example it will produce output something like this β
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-
If you run the above example it will produce output something like this β
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:
|
Complete Example-
Now let us combine both javascript and html parts. Here is the complete example β
If you run the above example it will produce output something like this β
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:
|
Complete Example-
Now let us combine both javascript and html parts. Here is the complete example β
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.
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:
|
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 β
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:
|
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 β
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:
|
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 β