我有以下指令:
.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}} _ dropDown div中的任何更改。我该怎么办?
答案 0 :(得分: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;
}
}