*
Previous AngularJS-QA-11 AngularJS-QA-13 Next

AngularJS Question Answers - 12

Question: When to use the an element while creating a directive in AngularJS?
Answer: Use an element when you are creating a component that is in control of the template.
Question: How to start AngularJS manually?
Answer: Use angular.bootstrap() to start AngularJS manually
Question: How to De-serialize from JSON string in AngularJS?
Answer: use angular.fromJson() to Deserialize from JSON string.
var ObjJson= '{"name":"Shiva","age":28,"city":"Benguluru"}';
  
document.write(angular.fromJson('{"x":11,"y":22,"z":33}'));  
document.write("</br>");
  
document.write(angular.fromJson(ObjJson));  
document.write("</br>");
Output:

[object Object]
[object Object]
Question: What is the purpose of the directive 'ng-model-options'?
Answer: ng-model-options: Specifies how updates in the model are done.
Question: How to check a reference is a date in AngularJS?
Answer: Use angular.isDate() which returns true if the reference is a date
var todayDate = new Date();  
var someDt = "12-12-2014";  
  
document.write(angular.isDate(todayDate));    
document.write("</br>");  
document.write(angular.isDate(someDt));
    
Output:
true
false
Question: What is the purpose of the directive 'ng-mousedown'?
Answer: ng-mousedown: Specifies a behavior on mousedown events.
Question: How to check a reference is a function in AngularJS?
Answer: Use angular.isFunction() which returns true if the reference is a function
function someName()  
{  
    return "www.gktoall.com";  
}  
var someStr = "www.gktoall.com";  
  
document.write(angular.isFunction(someName));    
document.write("</br>");  
document.write(angular.isFunction(someStr));
    
Output:
true
false
Question: What is the purpose of the directive 'ng-copy'?
Answer: ng-copy: Specifies a behavior on copy events.
Question: How do you check a reference is Object or not in AngularJS?
Answer: Use angular.isObject() which returns true if the reference is a object.
var someStr = "www.gktoall.com";  
var someObj = {'name' : 'Shiva'} ;
  
document.write(angular.isObject(someObj));    
document.write("</br>");  
document.write(angular.isObject(someStr));
    
Output:
true
False
Question: What is the purpose of the directive 'ng-include'?
Answer: ng-include: Includes HTML in an application.
Previous AngularJS-QA-11 AngularJS-QA-13 Next
*
*