为什么会有一个id=7的scope?有什么用?
<body ng-app="scopeExample">
<div class="show-scope-demo">
<div ng-controller="GreetController">
Hello {{name}}!
<div ng-controller="ListController">
<ol>
<li ng-repeat="name in names">{{name}} from {{department}}</li>
</ol>
<input ng-model="name">{{name}}
<div ng-include src="'child.html'">
</div>
</div>
</div>
</div>
</body>
child.html
<div ng-controller="ChildController">
<input ng-model="name">
</div>
我写过类angular的框架,一开始也提供了include功能,我的做法也是在外面套一个div,原因是什么呢,因为被include的 代码片段,不一定是一个被包裹起来的dom元素,很有可能是一组并排的div
例如:
child.html
所以针对这种情况,会在罪外层多包裹一层div再append到目标位置。我估计angular也是出于类似的考虑吧。。