ng-repeat with ng-include not working

前端 未结 3 817
梦毁少年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:20

    Using a directive worked for me: https://stackoverflow.com/a/24673257/188926

    In your case:

    1) define a directive:

    angular.module('myApp')
      .directive('mytemplate', function() {
        return {
          templateUrl: 'views/template.html'
        };
      });
    

    2) use your new directive:

    
    

    ... or if you're concerned about HTML validation:

提交回复
热议问题