In angularjs when using directive how to apply the scope(isolated scope) value update into many controller.
For example:
I have many templates in view page:
- left menu template
- top menu template
- right content template.
the above things using ui-router plugin. In this scenario right content have the controller name is ordersController.
Left menu template:
<a ng-custom-click data="data" href="#/order"> Orders </a>
List .. etc.
app.controller('myapp', function($scope){
$scope.data = {
list : true,
details : false,
test : "rk controller"
};
}
Directive code:
app.directive('ngCustomClick', function() {
return {
restrict : 'A',
replace : false,
controller : 'ordersController',
scope : {
data : '='
},
link : function(scope, el, attrs) {
el.bind('click', function(e) {
scope.data = {
list : false,
details : true,
test : "abcd directive"
};
});
}
};
});
Here ordercontroller is no relationship with left menu template.
So when click the link means the scope.data values need to change in ordercontroller.