Tutorialsplane

Angularjs check defined variable


Angularjs check defined variable : angular.isDefined() function is used to identify whether a variable is defined or not. Here in this tutorial we are going to explain how to check defined variables using the function angular.isDefined() in AngularJs. You can also use our online tool to run and edit the code.


Angularjs check defined variable | angular.isDefined | Example

To check a defined variable you can use angular.isDefined() function, it will return true if the variable is defined else it will return false. Here is an example of checking defined variable using angular.isDefined() function.

Angularjs check defined variable | angular.isDefined | Example:




 
 

  
<div ng-app="myApp">  
<div ng-controller="myController">  
    <button ng-click="chackDefinedVars()">Check Vars</button>
	<br/>
	Result for a = {{result1}}<br/>
	Result for b = {{result2}}
</div> 
</div>
  
                                                                                                                                                                                                                                                                                                                                                                                              

Try it ยป

After running the above example it will produce output something like this โ€“

AngularJs Api Refrence

AngularJs Directive