angularLocalStorage icon indicating copy to clipboard operation
angularLocalStorage copied to clipboard

storage.bind() doesn't work inside factory

Open sqwk opened this issue 11 years ago • 1 comments

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

sqwk avatar Jul 22 '14 18:07 sqwk

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.

renanlecaro avatar Sep 23 '14 07:09 renanlecaro