angular-local-storage icon indicating copy to clipboard operation
angular-local-storage copied to clipboard

Bind not watching deep with key like 'some.inner'

Open baumblatt opened this issue 8 years ago • 2 comments
trafficstars

Hello,

The bind function is not watching deep with key like some.inner because angular.isObject always returns false with call: isObject(scope[key])

The correct is object test must be: isObject($parse(key)(scope))

Possible related issues: #322

Best regards, Bernardo Baumblatt.

baumblatt avatar Jan 17 '17 07:01 baumblatt

Anyone who uses this feature have any thoughts?

grevory avatar Apr 18 '17 02:04 grevory

Hello Gregory,

Are you asking for a solution or an opinion? Well, I think that is the first option because of bug label.

In this case, my fault, I was not clear enough. Let me try again..

Actual Code:

var bindToScope = function(scope, key, def, lsKey, type) {

........

return scope.$watch(key, function(newVal) {
    addToLocalStorage(lsKey, newVal, type);
}, isObject(scope[key]));

Fixed Code:

var bindToScope = function(scope, key, def, lsKey, type) {

........

return scope.$watch(key, function(newVal) {
    addToLocalStorage(lsKey, newVal, type);
}, isObject($parse(key)(scope)));

So, and the fix goes to ... line 466!

Best regards, Bernardo Baumblatt

baumblatt avatar Apr 18 '17 03:04 baumblatt