angularLocalStorage icon indicating copy to clipboard operation
angularLocalStorage copied to clipboard

Angular binding problem

Open garagenisse opened this issue 11 years ago • 3 comments

Can't get this excellent tool to work for me when binding objects from cache to selectbox. When hitting F5 the value of the select is lost, the correct value is there but the select wont initiate correct.

Example: http://plnkr.co/edit/dpdANDKAq8eeHPMj5CbG?p=preview

Any ideas?

Regards Andreas

garagenisse avatar Apr 21 '14 16:04 garagenisse

Not sure what's going on, but add the cookie dependency http://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular-cookies.min.js

cDima avatar Apr 21 '14 17:04 cDima

Didn't help, whats going on is that above the upper drop a value is printed that's persisted in local storage, works fine on F5, but below that text the drop fails to initiate on that value "data-ng-init" should position the drop to the value printed above.

The lower drop is just there to test without local storage and works fine.

Regards Andreas

garagenisse avatar Apr 21 '14 18:04 garagenisse

I believe the problem stems from the tracking mechanism angular uses with object-based array of options. And, the version of angular you're using doesn't have the "track by" feature which would allow you to map object selections by an object property of your choosing, for example id. The only solution I could think of was to force the store bound variable to reference its matching object in the options array upon controller instantiation. (see plunker)

http://plnkr.co/edit/RsS4ylLMKedC5iyA35z9?p=preview

On Mon, Apr 21, 2014 at 1:27 PM, garagenisse [email protected]:

Didn't help, whats going on is that above the upper drop a value is printed that's persisted in local storage, works fine on F5, but below that text the drop fails to initiate on that value "data-ng-init" should position the drop to the value printed above.

The lower drop is just there to test without local storage and works fine.

Regards Andreas

— Reply to this email directly or view it on GitHubhttps://github.com/agrublev/angularLocalStorage/issues/46#issuecomment-40961198 .

thombrg avatar Apr 22 '14 01:04 thombrg