2016-01-18 140 views
0

,我有以下指令模板DIV:角指令观察更改

.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 
    } 
    } 

我想要做的是观察/看在{{ID}} _下拉格的任何变化。我该怎么做?

回答

1

您只需在链接函数中创建$ scope即可。

.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; 
     } 
}