How do I dynamically build an ng-include src?

寵の児 提交于 2019-12-03 04:24:55

ngInclude | src directive requires an angular expression, which means you should probably write

ng-src="'/modules/' + module.Id + '/tpl.html'"

From http://docs.angularjs.org/api/ng.directive:ngInclude

ngInclude|src string angular expression evaluating to URL. If the source is a string constant, make sure you wrap it in quotes, e.g. src="'myPartialTemplate.html'".

It might be better if you construct the url in model instead of inline HTML

<div ng-repeat="module in modules" id="{{module.Id}}">
    <ng-include src="module.url"></ng-include>
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!