0
我想創建一個angulajrs
可重複使用的html
組件,所以我可能不得不去directives
。我創建了一個簡單的,它不工作:如何使用angularjs指令創建可重用組件?
<my-fn info="test"></my-fn>
app.directive('my-fn', function() {
return {
restrict: 'E',
templateUrl: 'templates/my-fn.html',
scope: {
info: "=info"
}
};
});
我-fn.html:
<p>the value is: {{info}}</p>
結果:我沒有看到任何東西,並且在控制檯中沒有錯誤。
如何確保指令加載並找到模板?