我想在我的自定义指令中查看模型search.value
。
怎么做?
HTML:
<div search></div>
指令:
app.directive('search', function($rootScope) {
return {
restrict: 'A',
transclude: true,
scope: true,
templateUrl: 'template/app/inputSearch.html',
replace: true,
controller: function() {
},
link: function (scope, element) {
/* ... */
scope.$watch(......., function(value) {
});
}
};
});
模板:
<div class="search-parent">
<div class="search">
<input type="text" ng-model="search.value" />
</div>
</div>
答案 0 :(得分:1)
controller: function($scope) {
$scope.$watch('search.value', function(newVal, oldVal) {
});
}