我需要使用管道在Angular 6中创建一个搜索表单,并且必须将多个参数传递给管道.
nameSearch
,emailSearch
,roleSeach
,accountSearch
<tr *ngFor="let user of data | searchuser: nameSearch" ></tr>
Run Code Online (Sandbox Code Playgroud)
这是我的烟斗:
@Pipe({
name: 'searchuser'
})
export class SearchuserPipe implements PipeTransform {
transform(users: IUser[], nameSearch: string): IUser[] {
if(!users) return [];
if(!nameSearch) return users;
nameSearch=nameSearch.toLocaleLowerCase();
return users.filter(item=>
{
return item.desplayName.toLocaleLowerCase().includes(nameSearch)
});
}
Run Code Online (Sandbox Code Playgroud)
请指导我如何使用多参数创建管道搜索.
编辑:
transform(users: IUser[], nameSearch: string ,eamilSearch:string,roleSearch:string): IUser[] {
if(!users) return [];
if(!nameSearch) return users;
if(!eamilSearch) return users;
if(!roleSearch) return users;
nameSearch=nameSearch.toLocaleLowerCase();
return users.filter(item=>
{
item.desplayName.toLocaleLowerCase().includes(nameSearch),
item.email.toLocaleLowerCase().includes(eamilSearch),
item.description.toLocaleLowerCase().includes(roleSearch)
});
}
Run Code Online (Sandbox Code Playgroud) 我有这个通用类,我想使用该通用参数:
export class OperationResult<TResult>
{
public success: boolean;
public message: string;
public result: TResult;
constructor(success: boolean, message: string, result: TResult) {
this.success = success;
this.message = message;
this.result = result;
}
public static BuildSuccessResult(message: string, result: TResult): OperationResult<TResult> {
return new OperationResult<TResult>(true, message, result);
}
}
Run Code Online (Sandbox Code Playgroud)
但它向我显示了该BuildSuccessResult
函数的错误:
静态成员不能引用类类型parameters.ts
如何在静态函数上返回通用值?
我必须强制这些变量重复使用我想要使用的每一个,这让我很难.我需要创建一个类来定义这些变量并在整个程序中使用它们.我怎样才能做到这一点?
string RootFolderName = "Uplaod";
string ProductPictureFolder = "ProductPictureFolder";
string ProductMainPictureFolder = "ProductMainPicture";
string WebRootPath = _hostingEnvironment.WebRootPath;
string RootPath = Path.Combine(WebRootPath, RootFolderName);
string ProductPicturePath = Path.Combine(WebRootPath, RootFolderName, ProductPictureFolder);
string ProductMainPicturePath = Path.Combine(WebRootPath, RootFolderName, ProductPictureFolder, ProductMainPictureFolder);
string newPath = Path.Combine(WebRootPath, ProductMainPicturePath);
Run Code Online (Sandbox Code Playgroud) 我想删除部分文本,但我不知道该怎么做.
这是我的地址: https://localhost:44390/upload/productpic/productmainpic
我需要在我的地址中删除https://localhost:44390/
它:它应该是这样的:upload/productpic/productmainpic
我发现这条线"H"第一指数,但是当我需要找到"/"的upload
找到它/
的https://
.
现在我该怎么做呢?
c# ×2
angular ×1
angular-pipe ×1
angular6 ×1
asp.net-core ×1
javascript ×1
node.js ×1
typescript ×1