这是我的代码。 credit.creditSum - 这是我确定的数字。我在firefox中试过这个并且它有效。但是在chrome中没有。
<div *ngIf="credit" class="row">
<div class="span-12">
<!-- table content 1 -->
<div class="head_1">
<span class="title_1">{{credit.id}}</span>
<span class="title_summ">{{credit.creditSum | currency:'USD':true}}</span>
<span class="title_ccy">EUR</span>
</div>
<!-- end table content 1 -->
</div>
</div>
这是一个错误
EXCEPTION: TypeError: Cannot redefine property: length in [{{credit.creditSum | currency:'USD':true}} in CreditDetailsComponent@25:33] browser_adapter.ts:73
ORIGINAL EXCEPTION: TypeError: Cannot redefine property: length browser_adapter.ts:73
ORIGINAL STACKTRACE: browser_adapter.ts:73
TypeError: Cannot redefine property: length
at defineProperty (native)
答案 0 :(得分:2)
对我来说很好https://plnkr.co/edit/DfiZubmdsh5eaI6rkCGy?p=preview 该错误显然不是使用货币管道。
@Component({
selector: 'my-app',
providers: [],
template: `
<div>
<h2>Hello {{name}}</h2>
<span class="title_summ">{{credit.creditSum | currency:'USD':true}}</span>
`,
directives: []
})
export class App {
credit = {creditSum: 10};
constructor() {
this.name = 'Angular2'
}
}