html - 数字未以 Angular 4 显示为百分比

标签 html css angular

我需要在我的 Angular UI 中以百分比格式显示数字。目前它正在渲染实际值。因此,如果它是 2%,则显示为 0.02。我需要将其显示为 2%

<click-input contenteditable="true" *ngIf="item.fieldInfo.dataCategory == fieldCategories.percent" [classNames]="['percentage']">
    <input [(ngModel)]="item.value" name="item.fieldInfo.key"   required min="0" max="999999999999999"/>
</click-input>    

CSS

table {
    tbody {
        td {
            div.percentage {
                    padding:0.5rem;
                    &:after {
                        content: '%';
                    }
            }
        }
    }


}

最佳答案

尝试使用内置的 angular percent pipe相反

在您不可编辑的内容代码中,像这样使用它:

<div>{{item.value | percent}}</div>

关于html - 数字未以 Angular 4 显示为百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48689853/

相关文章:

javascript - curl :如何修复 "Please turn JavaScript on and reload the page"

javascript - 单击时全屏图像

html - CSS 无法更改 div 位置,这会导致裁剪

javascript - 滚动 div 元素时防止页面滚动

javascript - 如何以 Angular 2 - 4 递增变量

angular - 在 Angular 2 应用程序中使用 Material 单选按钮的问题

javascript - 如何使用按钮切换嵌套列表

我无法弄清楚的 Jquery .siblings( ) 错误

angular - Angular Material 中的 MdButton 和 MatButton 有什么区别?

html - 如何在 flex 容器中调整空 div