ng-repeat with ng-include not working

前端 未结 3 819
梦毁少年i
梦毁少年i 2021-02-14 19:07

I am trying to use an ng-repeat that includes an ng-include. The problem is that the first element in the ng-repeat is just the ng-include

3条回答
  •  清歌不尽
    2021-02-14 19:22

    First make sure that the data that is contained in the first index of items actually has the data that you want.

    One possible solution to your problem would be to simply not show the first index of the ng-repeat:

    This may not actually tackle the root of your problem, but it may still get your application working a bit more like what you expect.


    Another possible solution:

    see example here:

    http://plnkr.co/edit/Yvd73HiFS8dXvpvpEeFu?p=preview


    One more possible fix just for good measure:

    Use a component:

    html:

    js:

    angular.module("app").directive("myInclude", function() {
    return {
        restrict: "E",
        templateUrl: "/views/template.html"
    }
    })
    

提交回复
热议问题