Ng-click Not Working In Dynamically Created Content
I have this function in Angular where I add a new slide with a ng-click in it. var addSlide = function($scope, slideIndex, $event) { slideIndex++; var slider = angular.element(
Solution 1:
you need to add $compile service here, that will bind the angular directives like ng-click to your controller scope.Something like:
var divTemplate = '..your div template';
var temp = $compile(divTemplate)($scope);
Then append it to the HTML:
angular.element(document.getElementById('foo')).append(temp);
You can also bind the event to the div as following:
var div = angular.element("divID");
div.bind('click', $scope.addPhoto());
Post a Comment for "Ng-click Not Working In Dynamically Created Content"