formations/javascript/angular/scope-2.md

32 lines
679 B
Markdown
Raw Normal View History

# .cadoles-slide-title[L'objet $scope (2/4)]
**Contrôleurs et héritage prototypal des `$scope`**
```html
<html>
<body ng-app="myApp">
<div ng-controller="ParentCtrl">
{{parentProp}} <!-- "Foo" -->
<div ng-controller="ChildCtrl">
* {{parentProp}} <!-- "Foo" -->
{{childProp}} <!-- "Bar" -->
</div>
</div>
<script src="angular.js"></script>
<script>
var myApp = angular.module('myApp', []);
myApp.controller('ParentCtrl', ['$scope', function($scope) {
2015-04-08 23:22:53 +02:00
$scope.parentProp = "Foo";
}]);
myApp.controller('ChildCtrl', ['$scope', function($scope) {
2015-04-08 23:22:53 +02:00
$scope.childProp = "Bar";
}]);
</script>
</body>
</html>
```