gpt4 book ai didi

AngularJS : ng-include not working inside dynamic html

转载 作者:行者123 更新时间:2023-12-01 07:14:21 31 4
gpt4 key购买 nike

我是 AngularJS 的新手。我正在尝试使用 ng-include动态指令,但它不起作用。例如

var template = '<div ng-include="/app/partials/HtmlPage.html"></div>'

最佳答案

来自 Angular docs :
If the source is a string constant, make sure you wrap it in quotes, e.g. src="'myPartialTemplate.html'".
尝试将这些内引号添加到您的字符串模板名称中。
var template = '<div ng-include="\'/app/partials/HtmlPage.html\'"></div>'
(注意你必须转义你的内部引号,因为你已经在一个字符串中)

关于AngularJS : ng-include not working inside dynamic html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17754156/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com