Can we access model data of parent controller inside child controller
<div ng-controller="abc">
<div ng-controller="def">
<span> {{name}}</span>
</div>
</div>
can we access "model" value is it belongs in "abc" controller?
Can we access model data of parent controller inside child controller
<div ng-controller="abc">
<div ng-controller="def">
<span> {{name}}</span>
</div>
</div>
can we access "model" value is it belongs in "abc" controller?
Below code will help you. you can be able to access parent controller using $parent.
<script>
function abc($scope) {
$scope.name = "Pragnesh"
}
function def($scope) {
$scope.name = "Test"
}
</script>
<html ng-app="">
<body>
<div ng-controller="abc">
<div ng-controller="def">
<span> {{name}}</span>
<span> {{$parent.name}}</span>
</div>
</div>
</body>
Try using $parent (i.e. $scope.$parent), this will refer to the parent scope of a controller.
It is also explained here: AngularJS access parent scope from child controller