大佬教程收集整理的这篇文章主要介绍了角管用于去除双打,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
import { Pipe,PipeTransform } from '@angular/core'; @Pipe({ name: 'duplicates' }) export class DuplicatesPipe implements PipeTransform { transform(value: any,args?: any): any { return value; } }
在这里我的html下拉:
<strong class="ml-2">Country</strong> <SELEct class="ml-1" name="countryCode" [(ngModel)]="countryCode" (changE)="gender = ''" (changE)="activeStatus = ''"> <option></option> <option *ngFor="let customer of customerArray">{{Customer.countryCode | duplicates}}</option> </SELEct>
例如这样的事情:
@Pipe({ name: "uniqueCountryCodes" }) export class UniqueCountryCodesPipe implements PipeTransform { transform(customers: Customer[],args?: any): any { return customers.map(c => c.countryCodE).filter((code,currenTindex,allCodes) => allCodes.indexOf(codE) === currenTindeX); } }
用法:
<option *ngFor="let code of (customerArray | uniqueCountryCodes)">{{ code }}</option>
请记住,只要管道不是impure,它只过滤一次,并且在将新客户添加到customerArray时不会更新国家/地区代码.
以上是大佬教程为你收集整理的角管用于去除双打全部内容,希望文章能够帮你解决角管用于去除双打所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。