and I trigger this line of code after updating the Object:
this.form.reset();
the error occurred:
_ERROR TypeError: Cannot read property 'toString' of null
at StarRatingControlComponent.push../node_modules/angular-star-rating/esm5/angular-star-rating.js.StarRating.setRating (angular-star-rating.js:271)
at StarRatingControlComponent.push../node_modules/angular-star-rating/esm5/angular-star-rating.js.StarRatingControlComponent.setRating (angular-star-rating.js:774)
at StarRatingControlComponent.set [as rating] (angular-star-rating.js:73)
at StarRatingControlComponent.push../node_modules/angular-star-rating/esm5/angular-star-rating.js.StarRatingControlComponent.writeValue (angular-star-rating.js:762)
at forms.js:2066
at forms.js:3149
at Array.forEach ()
at FormControl.push../node_modules/@angular/forms/fesm5/forms.js.FormControl.setValue (forms.js:3149)
at FormControl.push../nodemodules/@angular/forms/fesm5/forms.js.FormControl.reset (forms.js:3190)
at forms.js:3572
Expected behavior
On line 271 of "angular-star-rating.js" the this._rating value should not be null to avoid the error.
I'm submitting a...
Current behavior
When using reactive forms in Angular 7 as this:
star-rating-control [starType]="'svg'" formControlName="rating" [step]="1" [rating]="0" [numOfStars]="5"></star-rating-control>
and I trigger this line of code after updating the Object:
this.form.reset();
the error occurred:
_ERROR TypeError: Cannot read property 'toString' of null at StarRatingControlComponent.push../node_modules/angular-star-rating/esm5/angular-star-rating.js.StarRating.setRating (angular-star-rating.js:271) at StarRatingControlComponent.push../node_modules/angular-star-rating/esm5/angular-star-rating.js.StarRatingControlComponent.setRating (angular-star-rating.js:774) at StarRatingControlComponent.set [as rating] (angular-star-rating.js:73) at StarRatingControlComponent.push../node_modules/angular-star-rating/esm5/angular-star-rating.js.StarRatingControlComponent.writeValue (angular-star-rating.js:762) at forms.js:2066 at forms.js:3149 at Array.forEach ()
at FormControl.push../node_modules/@angular/forms/fesm5/forms.js.FormControl.setValue (forms.js:3149)
at FormControl.push../nodemodules/@angular/forms/fesm5/forms.js.FormControl.reset (forms.js:3190)
at forms.js:3572
Expected behavior
On line 271 of "angular-star-rating.js" the this._rating value should not be null to avoid the error.
this.ratingAsInteger = parseInt(this._rating.toString(), 10);
Minimal reproduction of the problem with instructions
As I mentioned before the error occurs when the form reset() is performed.
Environment