工作版本角不工作1.0.7 plunkrngInclude曾在1.0.7但1.2.1
不工作的版本1.2.1角plunkr
在角1.0.7,以下ngInclude运行良好:
<li class="dropdown" id="header_notification_bar" data-ng-include="" src="'notifications.tpl.html'" data-ng-controller="NotificationsCtrl"></li>
notifications.tp.html看起来是这样的:
<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
<i class="icon-warning-sign"></i>
<span class="badge">{{notifications.length}}</span>
</a>
<ul class="dropdown-menu extended notification">
<li>
<p>You have {{notifications.length}} new notifications</p>
</li>
<li>
<ul class="dropdown-menu-list scroller" scroller style="height: 250px">
<li data-ng-repeat="n in notifications" >
<a href="#">
<span class="label label-success"><i class="icon-plus"></i></span>
{{n.summary}}
<span class="time">{{n.time}}</span>
</a>
</li>
</ul>
</li>
<li class="external" >
<a href="#">See all notifications <i class="m-icon-swapright"></i></a>
</li>
</ul>
在Angular 1.2.1中,模板被加载,但看起来该视图没有绑定到控制器/范围。
如果您运行上面的2个plunk并单击感叹号,您将看到只有Angular 1.0.7显示通知项目。
我已阅读“从1.0迁移到1.2”文档,发现here,但没有看到任何相关内容。也许我错过了一些东西。
任何帮助?
感谢, 丹
我没有看到底层原因 - 与由ngInclude和ngController创建的作用域不再共享 - 但将ng-controller声明移动到包装ul中似乎是一种解决方法。 [Plunk](http://plnkr.co/edit/0jfPVZYWwVY5BD7pOcwc?p=preview) – Sarah