*
Previous AngularJS-QA-12 AngularJS-QA-14 Next

AngularJS Question Answers - 13

Question: What is the purpose of the directive 'ng-init'?
Answer: ng-init: Defines initial values for an application.
Question: How to check a reference is defined in AngularJS?
Answer: Use angular.isDefined() which returns true if the reference is defined
var someObj;
var someStr = "www.gktoall.com";  
  
document.write(angular.isDefined(someObj));    
document.write("</br>");  
document.write(angular.isDefined(someStr)); 
    
Output:
false
true
Question: How do you check a reference is DOM element or not in AngularJS?
Answer: Use angular.isElement() which returns true if the reference is a DOM element
document.write(angular.isElement('html'));
    
Output:
false
Question: How to check a reference is a number in AngularJS?
Answer: Use angular.isNumber() which returns true if the reference is a number.
var someStr = "www.gktoall.com";  
var IsNum = 2322; 
  
document.write(angular.isNumber(IsNum));    
document.write("</br>");  
document.write(angular.isNumber(someStr));
Output:
true False
Question: What is the purpose of the directive 'ng-jq'?
Answer: ng-jq: Specifies that the application must use a library, like jQuery.
Question: What is the purpose of the directive 'ng-keydown'?
Answer: ng-keydown: Specifies a behavior on keydown events.
Question: What is the purpose of the directive 'ng-model'?
Answer: ng-model: Binds the value of HTML controls to application data.
Question: How do you check a reference is String or not in AngularJS?
Answer: Use angular.isString() which returns true if the reference is a string.
var someStr = "www.gktoall.com";  
var someObj = {'name' : 'Shiva'} ;
  
document.write(angular.isString(someObj));    
Document.write("</br>");  
document.write(angular.isString(someStr));
    
Output:
false
true
Question: How do you check a reference is Undefined in AngularJS?
Answer: Use angular.isUndefined() which returns true if the reference is Undefined
var someObj;
var someStr = "www.gktoall.com";  
  
document.write(angular.isDefined(someObj));    
document.write("</br>");  
document.write(angular.isDefined(someStr)); 
    
Output:
false
true
Question: What is the purpose of the directive 'ng-keypress'?
Answer: ng-keypress: Specifies a behavior on keypress events.
Back to Index
Previous AngularJS-QA-12 AngularJS-QA-14 Next
*
*