Update parent scope variable in AngularJS

后端 未结 5 1585
不思量自难忘°
不思量自难忘° 2020-11-27 10:45

I have two controllers, one wrapped within another. Now I know the child scope inherits properties from the parent scope but is there a way to update the parent scope variab

5条回答
  •  没有蜡笔的小新
    2020-11-27 11:32

    For accessing variables declared in the parent, we should use $parent in child controller or template file

    In controller

    $scope.$parent.varaiable_name
    

    In html template

    ng-model="$parent.varaiable_name"
    

提交回复
热议问题