1
为什么我不能从ng-include中的html中设置控制器ExampleCtrl的$ scope.myProperty的值。但是,如果我定义$ scope.myObj.myProperty和在HTML我推荐像ng-model="myObj.myProp"
工作正常?AngularJS:ng-include和示波器
例子:
<div ng-app="MyApp">
<div ng-controller='ExampleCtrl'>
<div ng-include="'#inlcude'"></div>
<!-- THIS DON'T WORK -->
<p><b>myProperty:</b>{{myProperty}}</p>
<!-- THIS WORK -->
<p><b>myObj.myProperty:</b>{{myObj.myProperty}}</p>
</div>
</div>
<!-- INCLUDE HTML -->
<div id='include'>
<input ng-model='myProperty' type='text' />
<input ng-model='myObj.myProperty' type='text' />
</div>
我明白泰德NG-包括创建一个新的范围,但为什么从的HTML包括我没有看到你的父母范围的简单欢迎使用属性?
感谢
谢谢!我发现你的[post](http://stackoverflow.com/questions/14049480/what-are-the-nuances-of-scope-prototypal-prototypical-inheritance-in-angularjs) – jlarghi 2013-03-06 20:22:59