2017-05-09 15 views
1

無効な属性をテキスト要素で使用しているスタイルが機能していません。どうして?無効な要素のスタイルが機能しません

<input pInputText [style]="{'padding-bottom':'10px','padding-top':'10px','width':'100%'}" 
         disabled="disabled" [(ngModel)]="selectedApprovalDate" /> 

それは、このエラー投げています:私はスタイル[style]="{'padding-bottom':'10px','padding-top':'10px','width':'100%'}"を削除した場合、それが働いているAssignment to read-only properties is not allowed in strict mode

を。どうして?

答えて

2

使用ngStyle代わり

<input pInputText [ngStyle]="{'padding-bottom':'10px','padding-top':'10px','width':'100%'}" 
        disabled="disabled" [(ngModel)]="selectedApprovalDate" /> 
+1

私はそれを試してみましょう。しかし、同じユーザーが両方の質問に答えました:P –

+0

それは解決策です。しかし、私は通常のスタイルが受け入れられない理由を知りたいですか? –

+1

エラーメッセージには 'style'プロパティは' readonly'なので、 http://stackoverflow.com/questions/24906279/how-to-set-element-style-property-in-strict-mode –

関連する問題