[英]Access controller from a directive within a directive that has isolated scope
[英]watching scope of controller from isolated scope in directive
我有一个下拉列表,在选择一个值时,控制器中的变量被更改,但watch指令未触发
<select ng-model="storesid" ng-change="changeVal(storesid)" ng-options="store.name for store in stores">
<option value="">
</option>
</select>
和使用它的控制器。
app.controller("segmentCtrl",function($scope,$rootScope,segmentService,lookupService){
$scope.changeVal = function(item){
$scope.timeSeries = item;
}
})
和指令
我在哪里看
.directive('timeseries1',function(){
return{
restrict:'E',
scope:{
val:'='
},
link:function(scope,element,attrs){
scope.$watch('timeSeries',function(){
})
}
}
})
<div ng-controller="segmentCtrl">
<timeseries1 id="dualAxisAreaContainer4" val="timeSeries" ></timeseries1>
</div>
在指令范围内,该变量称为“ val”。 因此,请注意可以。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.