0
我有孩子的应用程序控制器上复选框,所以当它的用户点击,我需要调用从父控制器的一些方法: 父应用程序控制器:调用父类的方法
<div ng-controller="ParentCntr as parentCntr">
<child-app></child-app>
</div>
儿童应用:
<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>
那么,如何以最简单的方式做到这一点?
尝试'$ parent.yourFunction()' – JeanJacques
ng-click =“parentCntr.myMethod()”? –
[AngularJS从子控制器访问父范围]的可能副本(https://stackoverflow.com/questions/21453697/angularjs-access-parent-scope-from-child-controller) – Vivz