Execute
<!DOCTYPE html> <html> <head> <title>Wikitechy AngularJS Tutorials</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"> </script> </head> <body ng-app="myApp"> <h2>Wikitechy Scope Hierarchies in AngularJS</h2> <div ng-controller="controller1"> <h3>Hello {{city}}!</h3> </div> <div ng-controller="controller2"> <ol> <li ng-repeat="name in names"> {{name}} from {{country}}, city: {{city}} </li> </ol> </div> <script> angular.module('myApp', []) .controller('controller1',['$scope', '$rootScope', function($scope, $rootScope) { $scope.names=['Jasmine','Mark']; $rootScope.country = 'UK'; $scope.city='London'; }]) .controller('controller2', ['$scope', function($scope) { $scope.names = ['Adam', 'Angel', 'Leo']; }]); </script> </body> </html>
www.wikitechy.com © Copyright 2016. All Rights Reserved.