重新编辑各位请看:link中我可以输出scope.type可是在templateURL中scope.type为undefined有点不懂directive的scope了,请各位指教谢谢
1 回答
![?](http://img1.sycdn.imooc.com/533e4d5b0001d57502200203-100-100.jpg)
慕盖茨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
提交
取消