我最近开始修改一个基于 Angular 6 的项目,但遇到了一些问题。因此,我有(假设)4 个 Mat-Select 字段,分别用于语言、货币、国家和组织。
最初所有下拉菜单都有 10 个默认值,我通过调用 API 来获取。我的要求是,一旦用户滚动到选择下拉菜单时打开的 Mat-Options 框的末尾,就进行另一个 API 调用。
我已经提到了这个问题,它工作正常,但有一些问题,我注意到了。该答案涵盖了一个领域的解决方案。如果我们使用多个字段,我们是否必须重复代码?
这是HTML
<mat-select [disabled]="isDisabled" [(ngModel)]="model.currency" name="currency" (selectionChange)="OnChange('currency',$event.value)" #currency>
<mat-option [value]="getCurrency.currencyCode" *ngFor="let getCurrency of fetchCurrency |
filternew:searchCurrencyvaluedrop">{{ getCurrency.currencyDescription }}
</mat-option>
</mat-select>
<mat-select [disabled]="isDisabled" [(ngModel)]="model.language" name="language"
(selectionChange)="OnChange('language', $event.value)" #language>
<mat-option [value]="getLanguage.languageDescription" *ngFor="let getLanguage of fetchLanguage |
filternew:searchLanguagevaluedrop">{{ getLanguage.languageDescription }}</mat-option>
</mat-select>
Run Code Online (Sandbox Code Playgroud)
为简单起见,我只添加了两个字段。以下是 .ts 中的代码:
viewIndex = 0;
windowSize = 10;
private readonly PIXEL_TOLERANCE = 3.0;
ngAfterViewInit() {
this.selectElemCu.openedChange.subscribe((event) =>
this.registerPanelScrollEventCurrency(event)
);
this.selectElem.openedChange.subscribe((event) => …Run Code Online (Sandbox Code Playgroud) 我现在被一个问题困扰了一段时间,正在寻找解决方案,但不幸的是,没有任何效果。
我正在屏幕上渲染 5 个表格。使用 GET 调用获取表数据。这些表格的渲染没有问题,但我无法在它们上实现分页。分页控件工作正常,但表数据未更新。我可以看到数组中的总元素,我可以使用方向键移动,更改页面大小,但对表格没有影响。表上粘着5条记录。
这是我的 .ts 文件
@ViewChild(MatPaginator) paginatorLegal: MatPaginator;
@ViewChild(MatPaginator) paginatorGSTN: MatPaginator;
@ViewChild(MatPaginator) paginatorPHYS: MatPaginator;
@ViewChild(MatPaginator) paginatorLink: MatPaginator;
// @ViewChild(MatPaginator, {read: true}) paginatorLink: MatPaginator;
@ViewChild(MatPaginator) paginatorAlias: MatPaginator;
ORGANIZATION_LINK //I removed it from Datasource object to see if it will somehow fix the issue.
DATASOURCES = {
LEGAL_ADDRESS: <any>[],
TELECOM_ADDRESS: <any>[],
GSTN_ADDRESS: <any>[],
PHYSICAL_ADDRESS: <any>[],
ORGANIZATION_ALIAS: <any>[]
}
ngOnInit() {
// this.organizationData.push(this.data['dataKey'])
this.cust_service.organizationToViewOrg.subscribe(data => {
this.organizationData = data
this.legalAddressTableCreation(data[0].legalAddress)
this.fetchTABLES();
})
}
fetchORGLINK() {
this.cust_service.getOrgLink(this.organizationData[0]['orgNumber'], resp => { …Run Code Online (Sandbox Code Playgroud)