我有一个需要传单指令的自定义指令,所以我可以访问控制器:
restrict: 'E',
require: '^leaflet',
scope: {
},
template: "",
link: function(scope, element, attrs, controller) {
}
当我在应用程序的控制器中使用我的自定义指令而不实现ng-repeat
时,它可以正常工作。像这样:
没有ng-repeat
<leaflet defaults="defaults" center="center" markers="markers" layers="layers" paths="paths">
<ng-include src="/markers.html" />
<my-directive
waypoints="wps">
</my-directive>
</leaflet>
控制器的JS没有ng-repeat
$scope.wps = [[32.745,-117.2776],[32.693,-117.3188]];
但是,当我尝试添加ng-repeat
时,我最终收到以下错误:
Error: [$compile:ctreq] http://errors.angularjs.org/1.3.12/$compile/ctreq?p0=leaflet&p1=myDirective
控制器的HTML ng-repeat
<leaflet defaults="defaults" center="center" markers="markers" layers="layers" paths="paths">
<ng-include src="/markers.html" />
<my-directive
ng-repeat="(name, data) in routes"
name="{{ name }}"
waypoints="data.wps">
</my-directive>
</leaflet>
控制器的JS与ng-repeat
$scope.routes = {
r1: {
wps: [[32.745,-117.2776],[32.693,-117.3188]]
}
}
我搞砸了什么?