How to access parent scope from child controller in AngularJS ?

devquora
devquora

Posted On: Feb 22, 2018

 

In angular there is a scope variable called $parent (i.e. $scope.$parent). $parent is used to access parent scope from child controller in Angular JS.
Example:


<div ng-controller="ParentCtrl">
    <h1>{{ name }}</h1>
    <p>{{ address }}</p>
    <div ng-controller="ChildCtrl">
        <h1>{{ title }}</h1>
        <input type="text" ng-model="$parent.address" />
</div>

    Related Questions

    Please Login or Register to leave a response.

    Related Questions