AngularJS - 一次性绑定在表

时间:2016-05-12 13:03:05

标签: angularjs performance ng-repeat

我不知道为什么这种一次性绑定不起作用。你能不能看看,如果外行可以,请告诉我?我正在使用角度1.4+(目前为1.4.10)

控制器:

'use strict';
angular.module('showcase.angularWay', ['datatables', 'ngResource'])
.controller('AngularWayCtrl', AngularWayCtrl);

function AngularWayCtrl($resource) {
    var vm = this;
    $resource('data.json').query().$promise.then(function(persons) {
        vm.persons = persons;
    });
}

查看:

<article class="main-content">
<header class="article-header">
    <h1><i class="fa fa-play"></i>&nbsp;The Angular way</h1>
</header>

<section class="showcase">
    <tabset>
        <tab heading="Preview">
            <article class="preview">
                <div ng-controller="AngularWayCtrl as showCase">
                    <table datatable="ng" class="row-border hover">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>FirstName</th>
                            <th>LastName</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="person in ::showCase.persons track by ::$index">
                            <td>{{ ::person.id }}</td>
                            <td>{{ ::person.firstName }}</td>
                            <td>{{ ::person.lastName }}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </article>
        </tab>
        <tab heading="HTML">
</section>

data.json返回如下所示的json: [{     “id”:870,     “firstName”:“Foo”,     “lastName”:“Whateveryournameis” }, ... ]

在巴塔朗,我看到了:

enter image description here

0 个答案:

没有答案