I have one problem. I'm using Angular localStoragee module to store settings, which i set in controller with:
localStorageService.set('localStorageKey','Add this!');
It's working very well but how can i watch localStorageKey for changes in directive, which takes it's value as a parameter?
I tried something like:
.directive('fooBar', function(localStorageService){
var linker = function(scope, element, attrs){
var unit = localStorageService.get('localStorageKey');
$watch('unit', function(){
console.log(unit);
});
}
return {
restrict: 'AE',
scope: {
value: '@dataValue'
},
replace: true,
link: linker
}
});
But no luck, i don't think i can watch variables like this. How can i solve this problem?
Thanks.