js外部調用更新angularjs的ng-repeat視圖問題
找了個開源基礎框架測試一下微信公眾號。沒想是用jquery做的restful風格的頁面。jquery更新table中數據就有些麻煩。所以用angularjs重構一下。
頁面中angularjs展示數據
<body ng-controller="multi">
<table id="baseTable" class="table table-striped table-bordered table-hover" >
<thead>
<tr><th style="width:10%" class="center">標題</th>
</tr>
</thead>
<body ng-controller="multi"> <tbody>
<tr ng-repeat="item in defaultData " >
<td class='center hidden-480'>{{item.title}}</td>
</tr>
</tbody>
</body>
</table>
</body>
外部jquery的ajax調用更新數據
</body>
</table>
</body>
外部jquery的ajax調用更新數據
var controllerScope = $('body[ng-controller="multi"]').scope();
controllerScope.defaultData=results;
controllerScope.$apply();
注意:外部js不要刪除了下面這段代碼塊。
<tr ng-repeat="item in defaultData " >
<td class='center hidden-480'>{{item.title}}</td> <tr ng-repeat="item in defaultData " >
</tr>
posted on 2017-09-11 21:37 傻 瓜 閱讀(763) 評論(0) 編輯 收藏 所屬分類: Ajax 、javascript