iam get some problems. i have an dynamic form input of rating parameter, i try use ionic3-star-rating module; https://www.npmjs.com/package/ionic3-star-rating. Package its work, but i cant bind dynamic value into my object.
the code like this ;
input-scanner.html
<div *ngFor="let dataP of dataParameter">
<ion-row class="parameter-input">
<ion-item text-center class="xgray">
<h4 class="h-title">{{dataP.name}}</h4>
</ion-item>
<ion-item no-padding text-center class="silver">
<ionic3-star-rating activeIcon="star" defaultIcon="star-outline" activeColor="#e6821e" defaultColor="#404040" readonly="false" [rating]="0">
</ionic3-star-rating>
</ion-item>
<ion-item class="item-input">
<ion-input type="text" placeholder="Masukkan notes.." [(ngModel)]="dataP.notes"></ion-input>
</ion-item>
</ion-row>
</div>
<button ion-button icon-only (click)="saveRecord(dataParameter)">
<ion-icon name="checkmark"></ion-icon>
</button>
input-scanner.ts
constructor(
public navCtrl: NavController,
public navParams: NavParams,
public events: Events,
public toastCtrl : ToastController,
public alCtrl : AlertController) {
events.subscribe('star-rating:changed', (starRating) =>
{
this.bindRatingId(1,starRating)
// how can i get id ; (1) dynamic from my event click the ionic3-star-rating?
});
}
ionViewDidLoad() {
this.getDataParameter();
}
bindRatingId(id,starRating){
console.log(starRating);
}
getDataParameter(){
var data = [
{"name":"FIRE BOX. No.157","id":1,"rating":"","notes":""},
{"name":"PIPA. No.158","id":2,"rating":"","notes":""},
{"name":"FIRE BOX. No.158","id":3,"rating":"","notes":""},
];
for(let v of data){
this.dataParameter.push(v);
}
}
saveRecord(data){
console.log(data);
}
when i click button saveRecord, the result is ;
[
{"name":"FIRE BOX. No.157","id":1,"rating":"5","notes":"some input"},
{"name":"PIPA. No.158","id":2,"rating":"","notes":""},
{"name":"FIRE BOX. No.158","id":3,"rating":"","notes":"" }
]
the rating value not dynamically set into my object :(,
because i set manual in the bindRatingId() just to set id=1 .
How can i get dynamically value from ionic3-star-rating module ? when i try to add [(ngModel)] in attributee, i have an error code . someone can help me please? thank you before it