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
});
}
};
});
I have the above AngularJS and when I run my page the Console.Log shows [cycle] terminating; too few slides: 0 and then it shows the Get Request after.
How would I be able to run the directive once the $http.get has finished?