AngularJS Tutorial 7:Controller Inheritance and nested controllers in AngularJS

Controller Inheritance or nested Controllers in AngularJS

<!DOCTYPE html>
<html>
<head>
    <script src="angular.min.js"></script>
    <meta charset="utf-8" />
    <script>
        var myApp = angular.module("myModule", [])

        myApp.controller("parentController", function ($scope) {
            $scope.name = "parent Controller";
        }
        );
        myApp.controller("firstLevelController", function ($scope) {
            //$scope.name = "parent Controller";
        }
        );
        myApp.controller("secondController", function ($scope) {
            $scope.name = "second level Controller";
        }
        );

    </script>
</head>
<body ng-app="myModule">
    <div ng-controller="parentController">
        Parent divison: {{name}}
        <div ng-controller="firstLevelController">
           First level : {{name}}
            <div ng-controller="secondController">
            SecondLevel    {{name}}
            </div>
        </div>
    </div>

</body>
</html>   

OUTPUT:
If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar