I have checkbox on child app controller, so when user click on it, I need to call some method from parent controller: Parent app controller:
<div ng-controller="ParentCntr as parentCntr">
<child-app></child-app>
</div>
Child app:
<div class="child-app" ng-controller="ChildCntr as childCntr">
<div class="checkbox no-indent">
<input type="checkbox"
name="test"
id="test"
ng-change="childCntr.DisableText()"
ng-model="childCntr.testVar"/>
<label for="test">Some Text</label>
</div>
</div>
So, how to do this in easiest way?
So to access to the parent scope you can use $parent like this :
<div ng-controller='SecondCtrl' ng-click='$parent.testFunction()'>{{$parent.name}}</div>
Here is a working example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.