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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -