中创建手动动画。
app.controller("MainController", function($scope, $http){
$scope.items= [];
console.log('hi');
$http.get('../assets/data/data.json').then(function(response) {
$scope.drinks =response.data.drinks;
});
});
app.directive('cycle', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
$(element).cycle({
fx: 'fade',
timeout: 10
});
}
};
});
我有上面的AngularJS,当我运行我的页面时,Console.Log显示[cycle] terminating; too few slides: 0
,然后显示Get Request
。
我如何能够运行指令一旦$http.get
已经完成?
试试
<div cycle ng-if="drinks"></div>
有两种用法
-
ng-cloak
-
ng-show
和ng-hide
和自定义scope
属性
还可以考虑使用动画而不是在指令