我想通过 searchtext ngModel 文本框搜索 *ngFor 值,我正在从 dexie indexeddb 包装器绑定 ngFor。在运行我的程序时出现一些错误,错误如下,请检查并帮助我。
Search.html 页面:
<div id="custom-search-input">
<div class="input-group col-sm-12">
<input type="text" class="form-control" placeholder="Search" [(ngModel)]="searchtext" />
<span class="input-group-btn">
<button class="btn btn-info" type="button">
<i class="glyphicon glyphicon-search"></i>
</button>
</span>
</div>
</div>
<br>
// here i'm using pipe filter
<div class="card" *ngFor="let group of listgroups | filter: searchtext">
<div class="card-header card-default col-sm-4 col-md-4 col-lg-4"><a> {{ group.GroupID }}</a>
</div>
<div class="card-block">
<p class="glyphicon glyphicon-user card-text card-default col-sm-8 col-md-8 col-lg-8">
{{ group.GroupName }} </p>
</div>
</div>
component.ts 页面:
import { Component,Pipes,PipeTransform } from '@angular/core';
import { SearchGroupService } from 'app/Services/searchgroup.service';
import { Router } from '@angular/router';
import { FilterPipe } from './filter.pipe';
@Component({
selector : 'search',
templateUrl : 'app/Views/searchgroup.html',
pipes: [FilterPipe],
providers: [SearchGroupService]
})
export class SearchGroupComponent implements PipeTransform {
id: id = [];
x: any;
name: name = [];
totalcount: any;
constructor(public rotuer: Router){
// this._searchgroupservice.getGroupService();private _searchgroupservice: SearchGroupService
// console.log(this._searchgroupservice.BindGroupDetails());
// this._searchgroupservice.BindGroupDetails();
// this.router = Router;
// var _this = this;
// this.router = router;
}
filter.pipe.ts 页面
import { Pipe,PipeTransform } from '@angular/core';
@Pipe({
name: 'filter'
})
export class FilterPipe implemnts PipeTransform{
transform(listgroups:any, searchtext:any):any {
var searchtext = this.searchtext;
var listgroups = this.listgroups;
if(searchtext === undefined) return listgroups;
return listgroups.filter(function(listgroups){
return listgroups.GroupID.toLowerCase().includes(searchtext.toLowerCase());
})
}
}
错误:
TypeScript transpiling to CommonJS, consider setting module: "system" in typescriptOptions to transpile directly to System.register format npmcdn.com/plugin-typescript@4.0.10/lib/logger:20
Failed to load resource: the server responded with a status of 404 (Not Found) http://127.0.0.1:58889/http-services/emulator-webserver/ripple/userapp/x/C/…nesh/Project/AngType_20161017/Test%20Old/www/app/Components/filter.pipe.ts
Error: (SystemJS) XHR error (404 Not Found) loading http://127.0.0.1:58889/http-services/emulator-webserver/ripple/userapp/x/C/Users/admin/Desktop/Dinesh/Project/AngType_20161017/Test%20Old/www/app/Components/filter.pipe.ts
Error: XHR error (404 Not Found) loading http://127.0.0.1:58889/http-services/emulator-webserver/ripple/userapp/x/C/Users/admin/Desktop/Dinesh/Project/AngType_20161017/Test%20Old/www/app/Components/filter.pipe.ts
at ZoneDelegate.invoke (http://127.0.0.1:58889/http-services/emulator-webserver/ripple/userapp/x/C/Users/admin/Desktop/Dinesh/Project/AngType_20161017/Test%20Old/www/node_modules/zone.js/dist/zone.js:203:28)
at Zone.runGuarded (http://127.0.0.1:58889/http-services/emulator-webserver/ripple/userapp/x/C/Users/admin/Desktop/Dinesh/Project/AngType_20161017/Test%20Old/www/node_modules/zone.js/dist/zone.js:110:47)
at XMLHttpRequest.<anonymous> (http://127.0.0.1:58889/http-services/emulator-webserver/ripple/userapp/x/C/Users/admin/Desktop/Dinesh/Project/AngType_20161017/Test%20Old/www/node_modules/zone.js/dist/zone.js:86:29)
Error loading http://127.0.0.1:58889/http-services/emulator-webserver/ripple/userapp/x/C/Users/admin/Desktop/Dinesh/Project/AngType_20161017/Test%20Old/www/app/Components/filter.pipe.ts as "./filter.pipe" from http://127.0.0.1:58889/http-services/emulator-webserver/ripple/userapp`enter code here`/x/C/Users/admin/Desktop/Dinesh/Project/AngType_20161017/Test%20Old/www/app/Components/searchgroup.component.ts**