gpt4 book ai didi

javascript - 添加 ng-repeat 导致错误 : $compile:ctreq

转载 作者:行者123 更新时间:2023-11-29 10:39:59 28 4
gpt4 key购买 nike

我有一个自定义指令需要 leaflet 指令以便我可以访问 Controller :

restrict: 'E',
require: '^leaflet',
scope: {

},
template: "",
link: function(scope, element, attrs, controller) {

}

当我在我的应用程序的 Controller 中使用我的自定义指令而没有实现 ng-repeat 时,它工作正常。像这样:

Controller 的 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>

Controller 的 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

Controller 的带有 ng-repeat

的 HTML
    <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>

Controller 的 JS 与 ng-repeat

$scope.routes = {
r1: {
wps: [[32.745,-117.2776],[32.693,-117.3188]]
}
}

我搞砸了什么?

最佳答案

你有 <ng-include src="/markers.html" />在你的指令之前。您需要明确关闭该标签。参见 this bug report .

关于javascript - 添加 ng-repeat 导致错误 : $compile:ctreq,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31011404/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com