ng g c shared/chips-list
用的chips控件。
1,完成自动建议表单控件模板。
<div [formGroup]="form" class="full-width"> <span>{{label}}</span> <mat-chip-list aria-label="Fish selection"> <mat-chip selected="true" color="primary" *ngFor="let member of members"></mat-chip> </mat-chip-list> <mat-form-field *ngIf="displayInput" class="full-width"> <input matInput type="text" [placeholder]="placeholderText" [matAutoComplete]="autoMembers" formControlName="membersearch" /> </mat-form-field> </div> <!--自动完成--> <mat-autocomplete #autoMembers="matAutocomplete" [displayWith]="displayUser"> <mat-option *ngFor="let item of memberResults$ | async" [value]="item" (onSelectionChange)="handleMemberSelection(item)"> {{item.name}} </mat-option> </mat-autocomplete>
import { FormGroup, NG_VALIDATORS, NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms'; import { Component, forwardRef, OnInit } from '@angular/core'; @Component({ selector: 'app-chips-list', templateUrl: './chips-list.component.html', styleUrls: ['./chips-list.component.scss'], providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => ChipsListComponent), multi: true }, { provide: NG_VALIDATORS, useExisting: forwardRef(() => ChipsListComponent), multi: true } ] }) export class ChipsListComponent implements OnInit, ControlValueAccessor { constructor() { } writeValue(obj: any): void { throw new Error('Method not implemented.'); } registerOnChange(fn: any): void { throw new Error('Method not implemented.'); } registerOnTouched(fn: any): void { throw new Error('Method not implemented.'); } ngOnInit(): void { } }
3,
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。