如何从localStorageService
中的directive
获取数据?
对此进行了尝试:var clientItem = localStorageService.get('clientData');
错误:无法读取未定义的属性“ get”
答案 0 :(得分:0)
答案 1 :(得分:0)
将服务注入到指令的构造函数中的指令中:
app.directive("myDirective", function (localStorageService) {
return {
link: postLink,
};
function postLink(scope,elem,attrs) {
var clientItem = localStorageService.get('clientData');
}
}