Ng-zorro-antd: Component - rate

Created on 17 Jul 2019  ·  4Comments  ·  Source: NG-ZORRO/ng-zorro-antd

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-start-mgn5yd

Steps to reproduce

Rating does not work correctly with fractional numbers.
Look in the console - https://ng-zorro-antd-start-mgn5yd.stackblitz.io

What is expected?

value 3.0 = 3 star

value 4.8 = 5 star

What is actually happening?

Rating value "3.0" != 3 star :(
3.0 half star != 3 star

| Environment | Info |
|---|---|
| ng-zorro-antd | 8.0.3 |
| Browser | Chrome 75.0.3770.100 |


JS value <= 0.5 // 🌗 value >= 4.5 // 🌕🌕🌕🌕🌕

Rate

Most helpful comment

it is quite clear that the rate only accept number, but you pass a string to the ngModel
The string is obviously not equal to a number
https://stackblitz.com/edit/ng-zorro-antd-start-ab1fc3?file=src/app/app.component.ts

All 4 comments

Also remove the margin for the last element.
last star margin
_Solution:_

li:not(:last-child) {
    margin-right: 8px;
}

it is quite clear that the rate only accept number, but you pass a string to the ngModel
The string is obviously not equal to a number
https://stackblitz.com/edit/ng-zorro-antd-start-ab1fc3?file=src/app/app.component.ts

The string is obviously not equal to a number

Oh yes, indeed, my carelessness😔, thanks🤝

And about the margin, my message is higher
Create a new issues about this ?

_Now I use:_

::ng-deep .ant-rate {
  li {
    margin: 0 4px 0 4px
  }
}

NG-ZORRO ANT Component Rate (Half star)

You can do it in the source code approximately as I said above.

For style problems, maybe you should send a pull request to ant design first because style files are synced from there.

Was this page helpful?
0 / 5 - 0 ratings