【发布时间】:2017-05-17 20:13:03
【问题描述】:
我知道这个问题有类似的问题得到解答,但没有一个解决方案对我有用。我有以下文件夹结构:
static
----calendar
--------calendar.controller.js
--------calendar.view.html
----home
--------home.controller.js
--------home.view.html
----app.js
----index.html
在 calendar.controller.js 中,我为我的日历创建了一个指令,如下所示:
.directive('myCalendar',function(){
return{
restrict:'E',
template:"calendar.view.html"
}
})
我正在尝试从 home.view.html 渲染该日历模板,但没有成功。
我的 home.view.html 中有这个:
<my-calendar></my-calendar>
在浏览器上它实际上显示了我试图让他绑定的路径(在浏览器上你可以看到“./calendar/calendar.view.html”)。我已经尝试以多种方式更改指令的路径:
- template:"./calendar.view.html"
- template:"/calendar.view.html"
- template:"./calendar/calendar.view.html"
- template:"/calendar/calendar.view.html"
...但它仍然无法正常工作。谢谢。
【问题讨论】:
-
试试
templateUrl而不是template -
- 完美!!非常感谢;)
标签: html angularjs templates bind directive