|
本帖最后由 amy 于 2016-3-2 19:27 编辑
- <!DOCTYPE html>
- <html>
- <head lang="en">
- <meta charset="UTF-8">
- <title>run方法</title>
- <script src="angular.min.js"></script>
- </head>
- <body ng-app="myApp">
- <div ng-controller="firstController">
- {{name}} {{age}} {{sex}}
- <div ng-controller="secondController">
- {{name}}
- {{sex}}
- {{age}}
- </div>
- </div>
- <script>
- var app = angular.module("myApp",[]);
- app.controller('firstController',['$scope','$rootScope',function($s,$r){
- $s.name="Amy";
- $s.sex = "woman";
- [b] $r.age = "30";[/b]
- }]);
-
- </script>
- </body>
- </html>
复制代码
age变量从父元素处继承,但是结果并没有出现,是什么原因呢? |
|