你的位置:首页 > 软件开发 > Java > Part 15 AngularJS ng init directive

Part 15 AngularJS ng init directive

发布时间:2016-04-24 01:00:20
The ng-init directive allows you to evaluate an expression in the current scope. In the following example, the ng-init directive ...

The ng-init directive allows you to evaluate an expression in the current scope.  In the following example, the ng-init directive initializes employees variable which is then used in the ng-repeat directive to loop thru each employee. In a real world application you should use a controller instead of ng-init to initialize values on a scope. 

<!DOCTYPE html><html ="http://www.w3.org/1999/xhtml"><head>  <title></title>  <script src='/images/loading.gif' data-original="Scripts/angular.min.js"></script></head><body ng-app>  <div ng-init="employees = [          { name: 'Ben', gender: 'Male', city: 'London' },          { name: 'Sara', gender: 'Female', city: 'Chennai' },          { name: 'Mark', gender: 'Male', city: 'Chicago' },          { name: 'Pam', gender: 'Female', city: 'London' },          { name: 'Todd', gender: 'Male', city: 'Chennai' }        ]">    <table>      <thead>        <tr>          <th>Name</th>          <th>Gender</th>          <th>City</th>        </tr>      </thead>      <tbody>        <tr ng-repeat="employee in employees">          <td> {{ employee.name }} </td>          <td> {{ employee.gender}} </td>          <td> {{ employee.city}} </td>        </tr>      </tbody>    </table>  </div></body></html>

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:Part 15 AngularJS ng init directive

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。