2017-05-17 43 views
0

我知道有類似的問題回答了這個問題,但沒有解決方案爲我工作。我有以下文件夾結構:我已經創建了我的日曆中的指令看起來像這樣指令中的角度html模板不會渲染

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" 
     } 
    }) 

我試圖呈現從回家的日曆模板.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" 

...但它仍然不起作用。謝謝。

+0

嘗試'templateUrl',而不是'template' –

+0

* - *完美!非常感謝;) –

回答

1
template:"calendar.view.html" 

是 你需要templateUrl一個錯誤: 「calendar.view.html」 代替

+0

謝謝!這工作! –