I am pretty new to angular
and I am facing a problem. Namely I am trying to input text type, then clear it up again and then set it again without interacting with the UI.
So here I have a little peace of the text
fields:
<div class="form-group">
<label for="titleText">Title</label>
<input type="text" class="form-control" [(ngModel)]="titleText" id="titleText" aria-describedby="titleText" placeholder="Title">
</div>
<div class="form-group">
<label for="authorText">Author</label>
<input type="text" class="form-control" [(ngModel)]="authorText" id="authorText" placeholder="Author">
</div>
And here is the angular
part:
authorText : string;
titleText : string;
durationText : string;
genreText : string;
//Set the values
this.durationText = this.song.duration; //Just a string
this.authorText = this.song.author;
this.genreText = this.song.genre;
this.titleText = this.song.title;
//Clear the values
jQuery('#editSongDialog').find("input,textarea,select")
.val('')
.end()
.find("input[type=checkbox], input[type=radio]")
.prop("checked", "")
.end();
So when I am trying to set the values and clear the values then set the values again (with new values), the all fields end up empty. But when I try to set the values and then override them with new values then it works.
My guess is that the .prop("checked", "")
gives the fields a value that does not accept a string
and thus it is not filling it.