3

我有一个需要传单指令的自定义指令,因此我可以访问控制器:

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]]
  }
}

我搞砸了什么?

4

1 回答 1

3

你有<ng-include src="/markers.html" />你的指令之前。您需要明确关闭该标签。请参阅此错误报告

于 2015-06-23T20:14:16.220 回答