In general, made an element that adds tags like SO:
<div class="form-group"> <div> <div class="row"> <label class="col-form-label col-sm-2" for="search">Теги</label> <div id="tag-editor" class="col-sm-10 form-control"> <span class="tag" *ngFor="let tag of selectedTags.values()">{{tag.name}}<a class="close" (click)="onRemove(tag)">×</a></span> <input id="tag-search" name="search" placeholder="Search" #searchTag (input)="doSearchTag(searchTag.value)" (keydown)="onKeyDown($event)" autocomplete="off" /> </div> </div> <div class="row"> <div id="search-results" class="col-sm-10 offset-md-2" *ngIf="searchResult&&searchResult.length>0"> <div class="search-result unselectable" *ngFor="let tag of searchResult" (click)="onSelectTag(tag)"> {{tag.name}} -> {{tag.description}}</div> </div> </div> </div> </div>
When you select an item from the list, it is added to the component collection, and then a span-rectangle with the tag name is drawn to the left.
Actually, the question is:
I can somehow cunningly hang this required and use a template variable, which would then be used in an expression like [disabled]="!tags.valid"
?
Сначала более подробно опишите проблему, которую вы сформулировали в заголовке. Поясните, как вы столкнулись с проблемой и что препятствует её решению.
- overthesanity