Eduardo Santos
Eduardo Santos

Reputation: 1

Angular directive observe a template div for changes

I have the following directive:

.directive('cmplt', function ($parse, $http, $sce, $timeout) {
  return {
     restrict: 'EA',
     template: '<div><input id='{{id}}_fieldInpt' /></div id='{{id}}_dropDown'><div></div>'
     link: function($scope, elem, attrs) {
         //code here
     }
  }

What i want to do is observe/watch any changes in the {{id}}_dropDown div. How can i do it?

Upvotes: 0

Views: 49

Answers (1)

rkalita
rkalita

Reputation: 575

You need just create the $scope in your link function.

.directive('angucomplete', function ($parse, $http, $sce, $timeout) {
    return {
        restrict: 'EA',
        template: '<div><input id='{{id}}_fieldInpt' /></div   id='{{id}}_dropDown'><div></div>'
        link: function($scope, elem, attrs) {
            $scope.id = 123;
        }
}

Upvotes: 1

Related Questions