i have this situation:
<somebutton></somebutton>
...
app.directive("somebutton", function(){
return {
restrict: "E",
scope: {
// not sure what i can do here
},
template: '<button ng-click="loadTemplate()" type="button">Text</button>',
link: function(scope, element){
scope.loadTemplate = function(){
//TODO: append "home.html" template inside body directive
}
}
}
});
...
<script type="text/ng-template" id="home.html">
<div>home</div>
</script>
...
<div body ></div>
另一种做法是在HTML中添加按钮而不是模板。
<button ng-click="loadTemplate()" type="button">Text</button>
然后可能有一个控制器,具有loadTemplate()
方法来加载模板。
但我不确定如何实现。
感到困惑吗?是的 :)
对这个问题有什么想法吗?
谢谢