Angularjs 1.2: include template in repeat

Deadly 提交于 2019-12-11 13:12:12

问题


I am moving to the last version of angularjs (1.2), and now it seems that i cant include templates in the repeater:

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

I can use directive with templateUrl but is there a way to do this with ng-include only ?

Thanks.

Note: this works with the latest stable angularjs version (1.0.7)


EDIT: Error log (latest Chrome version) on each repeat element:

TypeError: Cannot call method 'insertBefore' of null
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.js:3321:22
    at forEach (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.js:199:18)
    at Object.enter (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.js:3320:9)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.js:15947:24
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.js:6277:11
    at wrappedCallback (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.js:9042:59)
    at wrappedCallback (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.js:9042:59)
    at https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.js:9128:26
    at Object.Scope.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.js:9953:28)
    at Object.Scope.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular.js:9809:23)

回答1:


spooky-giraffe (v 1.2) is not a production release. Many of the jsfiddle and plunker examples found in the docs.angularjs.org pages no longer work since those examples auto-updated to version 1.2.

There are many feature updates and bug fixes in version 1.2, including a complete rewrite of ngAnimate, but still much work to be done before it becomes a stable release.




回答2:


This will work in the next release of angular.

I cloned the frameowkr, packaged it and added it to the plnkr, Here you go:
http://plnkr.co/edit/k6P4Yv19bUV0BC4VBL69?p=preview

The PR that reverted the breaking changes:
https://github.com/angular/angular.js/pull/3640



来源:https://stackoverflow.com/questions/18276876/angularjs-1-2-include-template-in-repeat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!