我仅使用具有多种方法返回不同模板的一个指令为我的Web应用程序设置基本模板。
到目前为止,我所做的与我称为服务
的方式相同服务
app.service('myService',function() {
let path = "app/api/";
return {
getStudentInfo: () => {
//Some Statement...
}
}
})
现在,以防我目前如何称呼指令。但似乎不起作用
指令
app.directive('baseTemplate',function() {
let path = "app/templates/"; // my basetemplate path folder
// I want to call specific methods returning the template I need.
return {
getcategory: () => {
return {
restrict: 'A',template: '<strong> HELLO WORLD! </strong>'
}
},getTable: () => {
return: {
restrict: 'A',template: '<table> SOME DATA! </table>'
}
}
}
})
这就是我在调用指令时所做的
HTML
<div base-template.getcategory>
//The Output should be <strong> HELLO WORLD! </strong>
</div>
<div base-template.getTable>
//The same as the above Out should <table> SOME DATA! </table>
</div>