angularLocalStorage
angularLocalStorage copied to clipboard
storage.bind() doesn't work inside factory
storage.bind() doesn't work inside a factory, I assume because there is no scope.
Passing an object doesn't work either:
app.factory('someFactory', function(storage) {
var settings = {
foo: 'bar',
lorem: 'ipsum'
}
storage.bind(settings,'foo');
});
This produces the error undefined is not a function at Object.publicMethods.bind
There is no reason to bind values out of a scope. One option is to make the factory a function which accepts a $scope as arg, add the value to it, and use the scope to watch the value.