指令中的Angular html模板不会呈现

时间:2017-05-17 20:13:03

标签: html angularjs templates bind directive

我知道这个问题有类似的问题,但没有一个解决方案适合我。我有以下文件夹结构:

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>

在浏览器上它实际上显示了我试图让他绑定的路径(在浏览器上你可以看到&#34; ./ calendar / calendar.view.html&#34;)。我曾尝试在很多方面改变指令的路径:

 - template:"./calendar.view.html"
 - template:"/calendar.view.html"
 - template:"./calendar/calendar.view.html"
 - template:"/calendar/calendar.view.html"

......但它仍然没有成功。谢谢。

1 个答案:

答案 0 :(得分:1)

 template:"calendar.view.html"

这是一个错误 你需要templateUrl:&#34; calendar.view.html&#34;  代替

相关问题