Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
409 views
in Technique[技术] by (71.8m points)

angular - Angular4 Rendered2 remove label text on addClass method

this is my Component template.

<div [formGroup]="form" class="form-group">
  <label [attr.for]="field.name" class="{{field.name}}Label form-control-label">{{field.label}}</label>

  <input [formControlName]="field.name" [id]="field.name" class="form-control {{field.name}}Control">
  <small id="{{field.name}}Help" class="form-text"></small>
</div>

After a validation process, is necessary add text-danger (CSS class) to Label, using Renderer2 Class (from Angular4)

const label = this.Render.selectRootElement('label[for="' + key + '"]');

this.Render.addClass(label, 'text-danger');

.addClass method, works fine with input and helper text (below input). But in label tags, this method DELETE my LABEL Text.

This is a bug? @angular 4.3.6

Form Before Validation

Image Before Validation

Form After Validation

Image After Validation

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...