Skip to content

Instantly share code, notes, and snippets.

@lvidarte
Forked from anonymous/index.html
Last active December 18, 2015 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lvidarte/a6f0dc1951acdee84372 to your computer and use it in GitHub Desktop.
Save lvidarte/a6f0dc1951acdee84372 to your computer and use it in GitHub Desktop.
Angular $scope inheritance
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<meta charset="utf-8">
</head>
<body ng-app="app">
<div ng-controller="NameController">
{{ name }}
{{ child }}
<div ng-controller="ChildController">
{{ name }}
{{ child }}
</div>
<input type="text" ng-model="child">
</div>
<script>
angular
.module('app', [])
.controller('NameController', function($scope) {
$scope.name = "First";
$scope.child = "Child";
})
.controller('ChildController', function($scope) {
$scope.name = "Second";
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment