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