重新编辑各位请看:link中我可以输出scope.type可是在templateURL中scope.type为undefined有点不懂directive的scope了,请各位指教谢谢
1 回答
慕盖茨4494581
TA贡献1850条经验 获得超11个赞
templateURL function 只有2个参数 elem 和 attr哦。不能访问scope,因为模版请求是在scope初始化之前。
可以通过属性传输,然后获取return 'customer-'+attr.type+'.html',或者
...
link: function(scope) {
scope.customerUrl = 'customer-'+scope.type+'.html'},
template: '<div ng-include="customerUrl"></div>'...添加回答
举报
0/150
提交
取消
