An Angular2 component to visualize a star rating bar, built for Ionic 2.
$ npm install --save ionic2-rating
import { Ionic2RatingModule } from 'ionic2-rating';
@NgModule({
imports: [
Ionic2RatingModule
]
})
export class AppModule {}
$ npm install --save [email protected]
In your component:
import { Ionic2Rating } from 'ionic2-rating';
@Component({
templateUrl: '...',
directives: [Ionic2Rating]
})
export class MyComponent {
private rate = 2.5;
}
<rating [(ngModel)]="rate"></rating>
If you want to make it read-only, use "readOnly" property:
<rating [(ngModel)]="rate" readOnly="true"></rating>
If you want to change the number of stars, use "max" property (default is 5):
<rating [(ngModel)]="rate" max="10"></rating>
You may also need to customize component styles:
ul {
padding: 0px;
&.rating li {
padding: 5px 10px;
background: none;
color: #ffb400;
ion-icon {
font-size: 30px;
}
}
}
Based on ionic-rating for Ionic 1: https://github.com/fraserxu/ionic-rating