简体   繁体   English

AngularJs指令模板不起作用

[英]AngularJs directive template not working

I have a problem with AngularJs directive. 我对AngularJs指令有疑问。 The directive is working fine when I'm using "template". 当我使用“模板”时,该指令运行良好。 But when I'm trying to work with "templateURL". 但是,当我尝试使用“ templateURL”时。

The js file of the directive and the html file for the template are in the same directory. 指令的js文件和模板的html文件位于同一目录中。 In the template file theres the same code as in the template field in my directive. 在模板文件中,有与我指令中的模板字段相同的代码。

我的指令

项目树

Why is this not working? 为什么这不起作用? I don't understand it. 我不明白

Thanks for your help! 谢谢你的帮助!

You need to provide the absolute path for the templateUrl field. 您需要为templateUrl字段提供绝对路径。 Try this, 尝试这个,

templateUrl : 'js/directive/test.html'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM