Tag Archives: angularjs online course

AngularJs Change Image Src URL


AngularJs Change Image Src URL : Sometimes we need to change the image source in angularjs. There are many ways to change the Image source in AngularJs. Here in this tutorial we are going to explain how you can change the image source in AngularJs. You can use our online editor to edit & run the code online.


AngularJs Change Image Src URL Example

You can change the image url simply as below –

AngularJs Change Image Src URL Example:

 
 

  

If you click on the change url button it will change the image source url with new url passed in the function method.

AngularJs Array Push


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


AngularJs Array Push Values | Example

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

AngularJs Array Push Values | 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 push elements in array in AngularJs.

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

AngularJs Array Push

AngularJs reload page


AngularJs reload page- There are many ways to reload the page in AngularJs. You can use location.reload() method to reload the current page. Here in this tutorial we are going to explain how you can reload a page using AngularJs. You can use our online demo try and edit the code online.


AngularJs reload page

You can use location.reload() method to reload the current page. Here is full example –

AngularJs reload page | Example:

 
 

  

Please make sure you have imported $window service in controller.

AngularJs remove spaces from string


AngularJs remove spaces from string- There are many ways to remove blank spaces from the string. You can use .replace() to replace all blank spaces occurrence from the string. Here in this tutorial we are going to explain how you can remove blank | NULL | empty spaces. You can use our online demo try and edit the code online.


AngularJs remove spaces from string | Example

You can use replace() method to remove the blank spaces from the string. The regular expression replace(/ /g,””) is used to remove all blank spaces from the given string. Here is full example –

AngularJs remove spaces from string | Example:

 
 

  
With Space = {{myString1}}
Without Space = {{myString2}}

Try it »

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

AngularJs remove spaces from string

AngularJs check empty array


AngularJs check empty array- It is very simple to check if an array is empty in AngularJs. You can just use the array.length property. Here in this tutorial we are going to explain how you can check if an array is empty. You can use our online demo try and edit the code online.


AngularJs check empty array | Example

array.length property is used to find the array length ie. size of array. It will give 0 if array is having no element.

AngularJs check empty array | Example:

 
 

  

Try it »

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

AngularJs set variable in view

Angularjs enable disable button


AngularJs set variable in view : The ng-disabled directive is used to enable-disable the buttons in angularjs. We sometimes need the enable-disable functionality in AngularJs. There are many ways to Add the enable-disable toggle functionality. Here we are going to explain the simplest one. You can use our online editor to edit and run the example code.


Angularjs enable disable button | Example

Let us go step by step to create the enable-disable functionality using the angularjs ng-disabled directive. You can the enable-disable functionality in angularJs as below

Html Part

Html Part Contains the following htmls –

Angularjs enable disable button | Example:

The above part will create the simple button which will be used to add the enable-disable functionality using the following javascript –

JavaScript Part

The JavaScript Part Contains the following script as below –

Angularjs enable disable button | Example:

 

Complete Part

Now let us combine both part javascript and html to create full example –

Angularjs enable disable button | Example:

 
 

  

Try it »

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

Angularjs enable disable button Example

Note : If you are using timeout function please make sure you have imported the $timeout service in controller as in above example.

AngularJs set variable in view


AngularJs set variable in view : We sometimes need to assign or update variable value in view. There are many ways to update the variable values in view. Here we are going to explain the simplest one. You can use our online editor to edit and run the example code.


AngularJs set variable in view | Update scope variable

You can set the scope variable simply as below-

Html Part

Html Part Contains the following part which sets the variable value –

AngularJs set scope variable in html view Example:

{{myVar='Hello World!'}} *if you don't want to display this just add display none css.

The above part will example will update the variable and you can access the updated value as below –

JavaScript Part

The JavaScript Part Contains the following script as below –

AngularJs set scope variable in view Example:

 

The update value can be accessed in controller as above.

Complete Part

Now let us combine both part javascript and html to create full example –

AngularJs set scope variable in html view Example:

 
 

  
{{myVar='Hello World!'}} *if you don't want to display this just add display none css.

Try it »

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

AngularJs set variable in view Example

AngularJs Change Button Color


AngularJs Change Button Color: There are many ways to change button color in angularjs. Here in this tutorial we are going to explain some of them. You can use our online editor to edit and try the code.


AngularJs Change Button Color onclick Example

You can use the ng-class to change the background color of the button. Let us go step by step –

JavaScript Part

JavaScript Part Contains the following script as below –

AngularJs Change Button Color Example :

 

Css Part

Css Part Contains the following style as below –

AngularJs Change Button Color ng-click Css :


Complete Part

Now let us create the full example as below-

AngularJs Change Button Text / Label Example :

 
 


  

Try it »

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

AngularJs Change Button Color

Set textarea value in AngularJs


Set textarea value in AngularJs – It is very simple to set the value attribute of the input field. Here in this tutorial we are going to explain how you can set the textarea value using angularjs. You can also use our online editor to edit and run the code online.


How to set textarea value in AngularJs | Example

Let us go step by step to set the textarea value example –

JavaScript Part

JavaScript Part Contains the following part as below –

Angularjs set input value Example :


Html Part

Html Part contains the following html as below –

Angularjs set input value example:



Complete Part

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

Angularjs set input value example

 
 

  


Try it »

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

AngularJs Set TextArea Value Example