Basic instructions for AngularJS study notes (init, repeat)
Basic instructions for AngularJS study notes (init, repeat)
<h3>ng-initInitialize variables</h3> <div ng-init="name='aurora';age='18'"> <p ng-bind="name+','+age"></p> <p>{{name+','+age}}</p> <p ng-bind="name"></p> <p ng-bind="age"></p> </div> <h3>ng-initInitialize the object</h3> <div ng-init="hero={name:'aurora',role:'sup',line:'The sun rises as usual regardless of wind or rain'}"> <p ng-bind="+','++','+"></p> <p ng-bind=""></p> <p ng-bind=""></p> <p ng-bind=""></p> </div> <h3>ng-initInitialize the array</h3> <div ng-init="heros=['Goddess of Dawn','Fallen Angel','Soul Lock Warden']"> <p ng-bind="heros[0]+','+heros[1]+','+heros[2]"></p> <p ng-bind="heros[0]"></p> <p ng-bind="heros[1]"></p> <p ng-bind="heros[2]"></p> </div> <h3>ng-controllerController</h3> <div ng-controller="contr-2"> First Name: <input type="text" ng-model="firstName"> Last Name: <input type="text" ng-model="lastName"> Full Name : <span>{{firstName + "," + lastName}}</span> Full Name : <span ng-bind="firstName + ',' + lastName"></span> </div> <h3>ng-repeatIterate over non-repetitive sets</h3> <div ng-init="names=[1,2,3]"> <ul> <li ng-repeat="x in names"> {{x}} </li> </ul> </div> <h3>ng-repeatIterate through the repeated collection</h3> <div ng-init="number=[1,2,2,3]"> <ul> <li ng-repeat="x in number track by $index"> {{x}} </li> </ul> </div> <h3>ng-repeatTraversal objects</h3> <div ng-controller="contr-3"> <ul> <li ng-repeat="(key,value) in object track by $index"> {{key+":"+value}} </li> </ul> </div> <h3>ng-repeatTraversal objects(In original order)</h3> <div ng-controller="contr-4"> <ul ng-repeat="obj in objs "> <li ng-repeat="(key,value) in obj "> {{key+":"+value}} </li> </ul> </div> <h3>ng-repeatTraversal objects(Detailed explanation of properties)</h3> <table ng-controller="contr-5"> <tr ng-repeat="(key, value) in objs "> <td>Student ID: <span ng-bind="$index"></span> </td> <td> <span ng-bind="key"></span>: <span ng-bind="value"></span> </td> <td>Is it an odd number? <span ng-bind="$odd"></span> </td> <td>Is it an even number? <span ng-bind="$even"></span> </td> <td>Ranking is the boss? <span ng-bind="$first"></span> </td> <td>Smallest ranking? <span ng-bind="$last"></span> </td> <td>Ranking middle? <span ng-bind="$middle"></span> </td> </tr> </table> <h3>ng-repeat start/end</h3> <div ng-controller="contr-6"> <div ng-repeat-start="(key,value) in objs"> <p>Student ID: <span ng-bind="$index"></span> </p> <p> <span ng-bind="key"></span>: <span ng-bind="value"></span> </p> </div> <div ng-repeat-end></div> </div>
The above is the entire content of this article, I hope you like it.
Related Articles
Highcharts Example Code for Using Highcharts in angular
This article mainly introduces the sample code of highcharts in angular, which is very practical. Friends who need it can refer to it.2017-09-09Angular implements search box and price upper and lower limit functions
This article mainly introduces the functions of Angular to implement the search box and price upper and lower limits, which have certain reference value. Interested friends can refer to it.2018-01-01Detailed explanation of AngularJS cross-page value transmission (ui-router)
This article mainly introduces a detailed explanation of AngularJS cross-page value transmission (ui-router). The editor thinks it is quite good. I will share it with you now and give you a reference. Let's take a look with the editor2017-08-08A brief discussion on Angular routing reuse strategy
This article mainly introduces a brief discussion of Angular routing reuse strategy. The editor thinks it is quite good. I will share it with you now and give you a reference. Let's take a look with the editor2017-10-10Detailed explanation of the referenced third-party libraries in Angular-Cli
This article mainly introduces a detailed explanation of the third-party library cited in Angular-Cli. The editor thinks it is quite good. I will share it with you now and give you a reference. Let's take a look with the editor2017-05-05Detailed explanation of Angular sorting example
This article introduces you the relevant knowledge of angular sorting through examples. It is very good and has reference value. If you need it, please refer to it.2017-06-06Dynamically create Angular components to implement popup window function
This article mainly introduces dynamic creation of angular components to implement popup windows. Friends who need it can refer to it.2017-09-09Analyzing Angular form verification from shallow to deep
This article mainly introduces the relevant information about analyzing Angular form verification from a shallow to deeper analysis. Friends who need it can refer to it.2016-07-07Summary of usage of AngularJS filter filter
This article mainly introduces the usage of AngularJS filter filter. Combined with the example form, it analyzes the functions, classification, usage techniques and custom filter implementation methods of filter filter. Friends who need it can refer to it.2016-12-12Angular method to send cross-site requests using $
This article mainly introduces Angular's method of using $ to send cross-site requests. It analyzes the problems encountered in sending cross-site requests and the corresponding solutions in combination with examples. It has certain reference value. Friends who need it can refer to it.2017-03-03