AngularJS enable directive once $http get finishes -
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 above angularjs , when run page console.log shows [cycle] terminating; few slides: 0 , shows get request after.
how able run directive once $http.get has finished?
try doing this
<div cycle ng-if="drinks"></div> that way element contains directive compiled in browser when drinks available
Comments
Post a Comment