| Start | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Angular expressions - Text vs. Number This example demonstrates how Angular expressions are evaluated when using Controller View
|
|||||||||||||||||||||
| ngIf
Unlike JavaScriptView DOM If |
|||||||||||||||||||||
| ngRepeat
ng-repeat an array Where: ng-repeat an object Where: filter your ng-repeat by user input Where: You can also display or reference the filtered items elsewhere by assigning the filter output an alias with ng-repeat-start and ng-repeat-end To repeat multiple DOM elements by defining a start and an end point you can use the Output:
It is important to always close Variables
Performance considerations Rendering If the objects in the collection have an identifier property, you should always Scope of ngRepeat
Here is a simple example showing how you can set a value in your parent scope from a click event inside of If there was only Nested ng-repeat You can also use nested ng-repeat. Here to access the index of parent ng-repeat inside child ng-repeat, you can use |
|||||||||||||||||||||
| ngCloak The `ngCloak` directive is used to prevent the Angular html template from being briefly displayed by the browser in its raw (uncompiled) form while your application is loading. - [View source](https://docs.angularjs.org/api/ng/directive/ngCloak) HTML
The See also: Preventing flickering (opens new window) |
|||||||||||||||||||||
| Built-In Directives Cheat Sheet
|
|||||||||||||||||||||
| ng-model-options
This directive accepts an expression that will evaluate to a definition object or a reference to a scope value. Example: The above example will attach a debounce effect of 500 milliseconds on Available object properties |
|||||||||||||||||||||
| ngInclude ng-include allows you to delegate the control of one part of the page to a specific controller. You may want to do this because the complexity of that component is becoming such that you want to encapsulate all the logic in a dedicated controller. An example is: Note that the Also, note that the Within the |
|||||||||||||||||||||
| ngCopy The Prevent a user from copying dataIn the controller |
|||||||||||||||||||||
| ngClick The The It is useful when you want to attach click events on buttons and handle them at your controller. This directive accepts an expression with the events object available as HTML Controller HTML HTML Controller When the button is clicked, an invocation of the |
|||||||||||||||||||||
| ngPaste The |
|||||||||||||||||||||
| ngOptions
With There is anther way of creating Above example using FULL EXAMPLE (opens new window) Lets see the above example in detail also with some variations in it. Data model for the example: Option tag generated on selection: Effects:
FULL EXAMPLE (opens new window) Option tag generated on selection: Effects:
FULL EXAMPLE (opens new window) Option tag generated on selection: Effects: Options will be grouped based on there FULL EXAMPLE (opens new window) Option tag generated on selection: Effects: "Apples" and "Limes" will be disabled (unable to select) because of the condition FULL EXAMPLE (opens new window) Option tag generated on selection: Effects: There is not visual change when using FULL EXAMPLE (opens new window) Option tag generated on selection: Effects:
FULL EXAMPLE (opens new window) All |
|||||||||||||||||||||
| ngModel With ng-model you can bind a variable to any type of input field. You can display the variable using double curly braces, eg As you type in the input field or change it in any way you will see the value in the paragraph update instantly. The ng-model variable, in this instance, will be available in your controller as You will need to refer to the controller's scope by pre-pending the controller's alias defined in the ng-controller attribute to the ng-model variable. This way you won't need to inject |
|||||||||||||||||||||
| ngClass Let's assume that you need to show the status of a user and you have several possible CSS classes that could be used. Angular makes it very easy to choose from a list of several possible classes which allow you to specify an object list that include conditionals. Angular is able to use the correct class based on the truthiness of the conditionals. Your object should contain key/value pairs. The key is a class name that will be applied when the value (conditional) evaluates to true. Angular will check the |
|||||||||||||||||||||
| ngSrc Using Angular markup like |
|||||||||||||||||||||
| ngList The The You can set the delimiter manually by assigning In this case the delimiter is set to a semi colon followed by a space. By default Example: A customer delimiter is set to be The input box will display with the content: |
|||||||||||||||||||||
| ngShow and ngHide The The Working JSBin Example (opens new window) Controller: View |
|||||||||||||||||||||
| ngDblclick The This directive accepts an expression HTML In the above example, the value held at the |
|||||||||||||||||||||
| ngPattern The Example: Lets say we want an Template: Controller: |
|||||||||||||||||||||
| ngHref ngHref is used instead of href attribute, if we have a angular expressions inside href value. The ngHref directive overrides the original href attribute of an html tag using href attribute such as tag, tag etc. The ngHref directive makes sure the link is not broken even if the user clicks the link before AngularJS has evaluated the code. Example 1 Example 2 This example dynamically gets the href value from input box and load it as href value. Example 3 |
|||||||||||||||||||||
| ngMouseenter and ngMouseleave The The HTML At the above example, when the user points his mouse over the The HTML Reusing the first example, now when the user takes him mouse pointer away from the div, the |
|||||||||||||||||||||
| ngDisabled This directive is useful to limit input events based on certain existing conditions. The
HTML
|
|||||||||||||||||||||
| ngRequired The It is used to optionally define if an HTML |
|||||||||||||||||||||
| ngValue Mostly used under |
Read Article
https://develop.horje.com/learn/1434/reference