A
A
Alexander Shirobokov2014-11-06 23:47:53
Angular
Alexander Shirobokov, 2014-11-06 23:47:53

How to change the property of another controller from one controller?

Example
And is it possible to somehow globally access the properties of any controller?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Arushanov, 2014-11-09
@konrin

Yes, as already answered here. via $parent.
There may be several situations
1) From the child to the parent
2) We need to get access from the parent to the child.
3) controllers at the same level
1) $scope.$parent.functionName();
2) You can do this: in the child we write something like this

$scope.$parent.functionName =  function(){

};

Well, then in the right place of the parent scope, just call this function.
3) Well, here the principle is similar. If 2 controllers are on the same level, then they have a common parent, you can pass through it.
Another option is
$rootScope.
$emit, $broadcast.
If you need to call a property or function of another controller already on the view. Then you can use the Controller Alias.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question