Closed Navin-vis closed 4 years ago
Hi @Navin-vis which version are you using? Do you mean to blank the star component with your mouse/touch, or with code? I am able to submit a value then blank the stars, you just have to hover over them to the left until 0 are filled in, then click and they should stay blank
Hi @hughjdavey I am using current version , I mean to say when i set the value it worked well but after submitting that value i want to blank the star value by code that mean when i set the value for the first time in the variable after submitting the value i use to blank the variable but it not set the star value blank
Ok I think I understand. You can use the setRating
method of NgxStarsComponent
to do this. Below is a small demo of some stars set to 4 stars when the page loads, and some buttons which use setRating
to change the rating via code at runtime. Does this help?
@Component({
template: `
<div style="padding: 5rem; display: flex; flex-direction: column; align-items: center;">
<ngx-stars [size]="4" [initialStars]="4"></ngx-stars>
<button style="margin-top: 1rem;" (click)="onSetStars(0)">Set to 0</button>
<button style="margin-top: 1rem;" (click)="onSetStars(1)">Set to 1</button>
<button style="margin-top: 1rem;" (click)="onSetStars(2)">Set to 2</button>
<button style="margin-top: 1rem;" (click)="onSetStars(3)">Set to 3</button>
<button style="margin-top: 1rem;" (click)="onSetStars(4)">Set to 4</button>
<button style="margin-top: 1rem;" (click)="onSetStars(5)">Set to 5</button>
</div>
`,
styles: []
})
export class ScratchComponent {
// @ts-ignore
@ViewChild(NgxStarsComponent)
starsComponent: NgxStarsComponent;
onSetStars(stars: number): void {
this.starsComponent.setRating(stars);
}
}
@Navin-vis did this solve your issue?
Hi @hughjdavey Yes mate it worked.... Thank you
Can't able to blank the star fill after submitting the value first time...