| Question: |
What is the purpose of the directive 'ng-form'? |
| Answer: |
ng-form: Specifies an HTML form to inherit controls from. |
| Question: |
What makes the angular.copy() method so powerful? |
| Answer: |
It creates a deep copy of the variable.
A deep copy of a variable means it doesn’t point to the same memory reference as that variable. Usually assigning one variable to another creates a “shallow copy”, which makes the two variables point to the same memory reference. Therefore if we change one, the other changes as well |
| Question: |
What is internationalization? How to implement internationalization in AngularJS? |
| Answer: |
Internationalization is a way in which you can show locale specific information on a website. AngularJS supports inbuilt internationalization for three types of filters: currency, date and numbers. To implement internalization, we only need to incorporate corresponding js according to locale of the country. By default it handles the locale of the browser. |
| Question: |
What is the purpose of the directive 'ng-disabled'? |
| Answer: |
ng-disabled: Specifies if an element is disabled or not. |
| Question: |
What is the purpose of the directive 'ng-focus'? |
| Answer: |
ng-focus: Specifies a behavior on focus events. |
| Question: |
What is the difference between ng-show/ng-hide and ng-if directives? |
| Answer: |
ng-show/ng-hide will always insert the DOM element, but will display/hide it based on the condition. ng-if will not insert the DOM element until the condition is not fulfilled.
ng-if is better when we needed the DOM to be loaded conditionally, as it will help load page bit faster compared to ng-show/ng-hide.
We only need to keep in mind what the difference between these directives is, so deciding which one to use totally depends on the task requirements. |
| Question: |
What is the purpose of the directive 'ng-hide'? |
| Answer: |
ng-hide: Hides or shows HTML elements. |
| Question: |
What is the purpose of the directive 'ng-href'? |
| Answer: |
ng-href: Specifies a url for the <a>element. |
| Question: |
How to programatically change or adapt the template of a directive before it is executed and transformed? |
| Answer: |
Use the compile function. The compile function gives access to the directive’s template before transclusion occurs and templates are transformed, so changes can safely be made to DOM elements. This is very useful for cases where the DOM needs to be constructed based on runtime directive parameters. |
| Question: |
How to disable a button depending on a checkbox’s state in AnglarJS? |
| Answer: |
Use the ng-disabled directive and bind its condition to the checkbox’s state.
<body ng-app>
<label><input type="checkbox" ng-model="checked"/>Disable Button</label>
<button ng-disabled="checked">Select me</button>
</body>
|