Prev Demo
AngularJS
>
Controller Scope Inheritence
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> <script> var app = angular.module('app', []); app.controller('GrandFatherController', ['$scope', function($scope) { $scope.GrandSirname = 'Mehta'; $scope.Name = 'Ram Dhyan '; }]); app.controller('FatherController', ['$scope', function($scope) { $scope.FatherSirname = 'Narayan'; $scope.Name = 'Sheo '; }]); app.controller('ChildController', ['$scope', function($scope) { $scope.Name = 'Shreeharsh'; }]); </script> </head> <body> <p>Controller Inheritance</p> <div ng-app="app" ng-controller="GrandFatherController"> Grand father name : {{ Name }} {{ GrandSirname }} <div ng-controller="FatherController"> Father name : {{ Name }} {{ FatherSirname }} {{ GrandSirname }} <div ng-controller="ChildController"> Child name : {{ Name }} {{ FatherSirname }} {{ GrandSirname }} </div> </div> </div> </body> </html>
Note: We DO NOT save your trial code in our database.
Output