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
完成后,我怎样才能运行指令?