adding ng-repeat is causing Error: $compile:ctreq
adding ng-repeat is causing Error: $compile:ctreq
我有一个自定义指令需要 leaflet 指令以便我可以访问控制器:
restrict: 'E',
require: '^leaflet',
scope: {
},
template: "",
link: function(scope, element, attrs, controller) {
}
当我在我的应用程序的控制器中使用我的自定义指令而不实施 ng-repeat
时,它工作正常。像这样:
控制器的 HTML 没有 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]]
}
}
我搞砸了什么?
您的指令前有 <ng-include src="/markers.html" />
。您需要明确关闭该标签。参见 this bug report。
我有一个自定义指令需要 leaflet 指令以便我可以访问控制器:
restrict: 'E',
require: '^leaflet',
scope: {
},
template: "",
link: function(scope, element, attrs, controller) {
}
当我在我的应用程序的控制器中使用我的自定义指令而不实施 ng-repeat
时,它工作正常。像这样:
控制器的 HTML 没有 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]]
}
}
我搞砸了什么?
您的指令前有 <ng-include src="/markers.html" />
。您需要明确关闭该标签。参见 this bug report。