scotttrinh/angular-localForage

ngRepeat

Opened this issue · 7 comments

Its possible use ngRepeat with this directive? Same that

<input type="checkbox" 
    ng-repeat="i in settSchema.typeLocal"
    local-forage="{key: 'settings', name: 'typeLocal.i', scopeKey: 'settings.typeLocal.i', defaultValue: false"
    ng-model="settings.typeLocal.i">

or need create a new key?

hmm it should work, I haven't tried though

For me yes, but the peevish nodejs dislikes, as it says Error: You must use the name of an existing instance.

ok, one problem here is that name and key are strings, not scope values, so you're storing all your repeated data under the same name/key combination...

Same

ng-repeat="i in settSchema.typeLocal" 
local-forage="{key: 'settings', name: typeLocal.i, scopeKey: settings.typeLocal.i, defaultValue: false}"
ng-model="settings.typeLocal.i" 
1     159109   error    Error: You must use the name of an existing instance

Excuse me, you saw that I change the last comment?

Sorry, the error has nothing to do with the ng repeat. It's because you're using the parameter "name", but you probably haven't config the provider to create an instance of that name: https://github.com/ocombe/angular-localForage#configure-the-provider-

The default instance name is "lf": https://github.com/ocombe/angular-localForage/blob/master/src/angular-localForage.js#L21

If you remove the parameter "name", it should work

I've been testing and I've seen the ngRepeat instance variable that affects only scopeKey

ng-repeat="(key, data) in settings.kindLocal"
local-forage="{
key: kindLocal.key,

Like this return TypeError: model.assign is not a function in
https://github.com/ocombe/angular-localForage/blob/master/src/angular-localForage.js#L376

key: 'kindLocal.key',

Its at same key for all.

name: 'settings', 
scopeKey: 'settings.kindLocal[key]', 
defaultValue: data}"

Like this defaultValue is data, not variable data but string data. Needless to say, use 'data' its a same.
And use settings.kindLocal[key] its the first value of the loop.

ng-model="settings.kindLocal[key]">
{{ key }} {{ settings.kindLocal[key] }} === {{ data }}

Its seems to me ngRepeat not work with this directive.
It would be interesting to choose the storeName/table.
What do you think? And thanks for all.