IvRRimUm IvRRimUm - 2 months ago 19
TypeScript Question

How to pass an argument into propertyChange?

So the title is pretty self explanatory.

<Switch *ngIf="item.type=='checkbox'" [item]="item" (propertyChange)="onAttributeSwitchChange" row="1" checked="false"></Switch>


public onAttributeSwitchChange(args: observable.PropertyChangeData) {
console.dir(args);

//console.log(args.propertyName + " has been changed and the new value is: " + args.value);
if (args.propertyName === "checked") {
} else {

}
}


I need to get the
item
into the
onAttributeSwitchChange


And also, i need to make
onAttributeSwitchChange
working, because its not now(When i change value the
console.dir
doesn't fire).

Reference: https://github.com/NativeScript/NativeScript/issues/1353

Answer

Thanks @alexis-cramatte for the tip :)

But here's what worked:

In (Nativescript) NG2 you can access the properties by the ID. <Switch #switch *ngIf="item.type=='checkbox'" row="1" checked="false" (checkedChange)="onAttributeSwitchChange(switch.checked)"></Switch>

switch - Sets the ID

and then you can use the properties of the object by - switch.[propertyhere] - for example: switch.checked

Comments