I have a portion of view that refreshes itself, say the div hides when an API call is in progress and shows up when the response is obtained.
This portion of view (div) has a angular directive.
View
<div ng-controller="myCtrl> <input type="button" ng-click="callAPI()"> <div ng-show="isAPICallComplete"> <p data-my-directive="something" ng-repeat="name in names">{{name}}</p> </div> </div> Directive
angular.module('myModule') .controller('myCtrl', function ($scope, $http) { $scope.callAPI = function () { $http.get('someURL').then(function (response) { $scope.isAPICallComplete = true; $scope.names= response.names; }); } }) .directive('myDirective', function () { return { restrict: 'A', link: function (scope, element, attrs) { console.log('reached directive'); } } }); With the above code, on page load the API call is already complete and hence the div shows up which then invokes the angular directive and I could see the log in console. But when on other conditions the API is called, the div hides itself and shows up again. In this case, the angular directive is not invoked (I don't see the console log message).