本文實(shí)例講述了Angular封裝搜索框組件操作。分享給大家供大家參考,具體如下:
茫崖網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),茫崖網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為茫崖上千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)營(yíng)銷網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的茫崖做網(wǎng)站的公司定做!后臺(tái)管理系統(tǒng)多是以表格和表單為主,有列表就一定會(huì)有列表的篩選功能,所以在此把列表頭部的搜索功能拆分出一個(gè)公共組件,方便使用。
大致樣式如下圖:
這里我使用的是ng-zorro螞蟻金服的angular組件庫
index.html:
<div nz-form class="ant-advanced-search-form"> <nz-row [nzGutter]="24"> <nz-col [nzSpan]="8" *ngFor="let item of columns, let i=index" [style.display]="(i>2 && !expandForm) ? 'none' : 'block'"> <nz-form-item nzFlex> <nz-form-label >{{item.label}}</nz-form-label> <nz-form-control> <input nz-input [(ngModel)]="searchData[item.key]" placeholder="請(qǐng)輸入" *ngIf="item.type === 'input'"> <nz-select [(ngModel)]="searchData[item.key]" nzPlaceHolder="請(qǐng)選擇" *ngIf="item.type === 'select'"> <nz-option *ngFor="let son of item.data; let idx = index" [nzLabel]="son.label" [nzValue]="son.value"></nz-option> </nz-select> <nz-select [(ngModel)]="searchData[item.key]" nzPlaceHolder="請(qǐng)選擇" *ngIf="item.type === 'gender'"> <nz-option nzLabel="女" nzValue=0></nz-option> <nz-option nzLabel="男" nzValue=1></nz-option> </nz-select> <nz-select [(ngModel)]="searchData[item.key]" nzPlaceHolder="請(qǐng)輸入" *ngIf="item.type === 'operator'" nzAllowClear nzShowSearch [nzServerSearch]="true" (nzOnSearch)="onSearch($event)" (ngModelChange)="changeOption($event)"> <ng-container *ngFor="let opt of operatorOptions"> <nz-option [nzValue]="opt" [nzLabel]="opt.name + '-'+ opt.user_type"></nz-option> </ng-container> </nz-select> <nz-select [(ngModel)]="searchData[item.key]" nzPlaceHolder="請(qǐng)輸入" *ngIf="item.type === 'merchant'" nzAllowClear nzShowSearch [nzServerSearch]="true" (nzOnSearch)="onSearch_merchant($event)"> <ng-container *ngFor="let opt of merchantOptions"> <nz-option [nzValue]="opt.id" [nzLabel]="opt.name"></nz-option> </ng-container> </nz-select> <nz-select [(ngModel)]="searchData[item.key]" nzPlaceHolder="請(qǐng)輸入" *ngIf="item.type === 'client'" nzAllowClear nzShowSearch [nzServerSearch]="true" (nzOnSearch)="onSearch_client($event)"> <ng-container *ngFor="let opt of clientOptions"> <nz-option [nzValue]="opt.id" [nzLabel]="opt.name"></nz-option> </ng-container> </nz-select> <nz-select [(ngModel)]="searchData[item.key]" nzPlaceHolder="請(qǐng)輸入" *ngIf="item.type === 'admin'" nzAllowClear nzShowSearch [nzServerSearch]="true" (nzOnSearch)="onSearch_admin($event)"> <ng-container *ngFor="let opt of adminOptions"> <nz-option [nzValue]="opt.id" [nzLabel]="opt.name"></nz-option> </ng-container> </nz-select> <nz-date-picker *ngIf="item.type === 'date'" [(ngModel)]="searchData[item.key]"></nz-date-picker> </nz-form-control> </nz-form-item> </nz-col> <nz-col [nzSpan]="8" [hidden]="filterLength >= 3"> <button nz-button type="submit" nzType="primary" [nzLoading]="loading" (click)="submit()">查詢</button> <button nz-button type="reset" (click)="resetData()" class="mx-sm">重置</button> </nz-col> </nz-row> <nz-row [hidden]="filterLength < 3"> <nz-col [nzSpan]="24" > <button nz-button type="submit" nzType="primary" [nzLoading]="loading" (click)="submit()">查詢</button> <button nz-button type="reset" (click)="resetData()" class="mx-sm">重置</button> <a (click)="expandForm = !expandForm" *ngIf="filterLength > 3"> {{expandForm ? '收起' : '展開'}} <i class="anticon" [class.anticon-down]="!expandForm" [class.anticon-up]="expandForm"></i> </a> </nz-col> </nz-row> </div>
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
文章名稱:Angular封裝搜索框組件操作示例-創(chuàng)新互聯(lián)
URL鏈接:http://www.rwnh.cn/article48/dscgep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、域名注冊(cè)、網(wǎng)站設(shè)計(jì)公司、虛擬主機(jī)、軟件開發(fā)、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容