ada*_*101 9 angularjs angularjs-ng-repeat
我们有一个大型模型,ng-repeat需要几秒钟才能将模型中的所有项目绑定到表单.我们想展示一个旋转器,而这正在发生.绑定完成时是否会触发某些事件,因此我们知道何时隐藏微调器?
Nat*_*son 11
Plunkr:http://plnkr.co/edit/GzzTW4?p = preview
使用ng-show如果您使用的是1.2使用的微调ng-if
<div ng-controller="Ctrl">
<div ng-show="complete">Complete={{complete}}</div>
<div class="thing" ng-repeat="thing in things" my-post-repeat-directive>
thing {{thing}}
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在你的指令中使用$ last来确定渲染是否完成,然后更改你定义了ng-show/ngif的变量.
function Ctrl($scope) {
$scope.complete=false;
$scope.doComplete = function() {
$scope.complete = true;
}
$scope.things = [
'A', 'B', 'C'
];
}
angular.module('myApp', [])
.directive('myPostRepeatDirective', function() {
return function(scope, element, attrs) {
if (scope.$last) {
scope.$eval('doComplete()');
}
};
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16313 次 |
| 最近记录: |