Answer the question
In order to leave comments, you need to log in
How to change the value of a variable in a directive when it changes in a controller?
For example, I have this directive:
.directive('myDir',function(){
return {
restrict : 'E',
scope: {
first : '=',
second: '='
},
template : '{{first}}',
link : function(scope,el,attr){
scope.second = 'from directory and '+ scope.first;
}
}
})
<my-dir data-first="FromCtrl" data-second="directoryresult"></my-dir>
<br>
{{directoryresult}}
<button ng-click="ChangeFromCtrl()">срфтпу</button>
.controller('MyCtrl', function($scope) {
$scope.FromCtrl = 'love';
$scope.ChangeFromCtrl = function(){
$scope.tst = 'pice';
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question