angular2gridster icon indicating copy to clipboard operation
angular2gridster copied to clipboard

Confused about data binding implementation

Open IAMtheIAM opened this issue 7 years ago • 2 comments
trafficstars

Hi, In your demo app you have

        <input id="floating" type="checkbox" [(ngModel)]="gridsterOptions.floating" value="false"
            (change)="gridster.setOption('floating', gridsterOptions.floating)">

However, the (change)="gridster.setOption('floating', gridsterOptions.floating)" appears to do the same thing as [(ngModel)]="gridsterOptions.floating".

When I remove the change expression and leaving ngmodel, checking and unchecking the floating box still works as anticipated. However when removing the ngmodel expression and leaving change, checking and unchecking the floating checkbox does not actually change the ability to float the items.

So can you please explain what the purpose of (change)="gridster.setOption('floating', gridsterOptions.floating)" is and when it will be invoked?

Lastly, it seems the value=false has no effect since the value is set in the component under gristerOptions.floating - what is the purpose of setting this attribute here?

Thanks for the help.

IAMtheIAM avatar Dec 20 '17 18:12 IAMtheIAM

Hi, this specific option does not require setOptionmethod to be called, but others like e.g. dragAndDrop, resizable, lanes etc. do require. This can be a little confusing for the user, so I will leave this ticket open to provide more consistent way of changing gridster options.

swiety85 avatar Dec 22 '17 15:12 swiety85

Oh I see, thanks for the clarification. Yea, maybe some Docs enhancement to explain which methods require (change)="grister.setOption() vs which one can be done with [(ngModel)] or another way.

IAMtheIAM avatar Dec 26 '17 16:12 IAMtheIAM