32 lines
679 B
Markdown
32 lines
679 B
Markdown
|
# .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) {
|
||
|
* $scope.parentProp = "Foo";
|
||
|
}]);
|
||
|
|
||
|
myApp.controller('ChildCtrl', ['$scope', function($scope) {
|
||
|
* $scope.childProp = "Bar";
|
||
|
}]);
|
||
|
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|
||
|
```
|