Skip to content

Instantly share code, notes, and snippets.

@aeisenberg
Last active August 29, 2015 14:04
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 aeisenberg/07cbf18afcb68bddbc96 to your computer and use it in GitHub Desktop.
Save aeisenberg/07cbf18afcb68bddbc96 to your computer and use it in GitHub Desktop.
Nested scopes in angular behave strangely because of prototypal inheritance.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.js"
type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
angular.module('watchingApp', [])
.controller('watchedController', function($scope) {
$scope.value = 9;
})
.controller('watchingController', function($scope) { });
</script>
</head>
<body ng-app="watchingApp">
<div ng-controller="watchedController">
Value is {{value}}.
<br />
<div ng-controller="watchingController">
Value is {{value}}.
<br />
<textarea ng-model="value">{{value}}</textarea>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment