我有两个 HTML 按钮“上一个”和“下一个”。我使用这些按钮导航到不同的选项卡(组件)。该代码在 Chrome 和 Firefox 中按预期工作,但在 IE 或 Edge 中单击下一个和上一个按钮时会出现空白屏幕。
“下一步”按钮事件处理程序:
saveAndNextClick(form: FormGroup, section: string) {
this.markFormGroupTouched(form);
if (form) {
if (section === 'lastsection') {
this.sectionChangeService.change('schoolSection');
} else {
this.hideShowTabSection();
this.selectedSectionGroup[section] = false;
}
}
this.saveData();
this.saveService.saveQuestion();
}
模板
<div class="d-flex app-question-navigation justify-content-between">
<a class="btn btn-secondary buttonSize (click)="previousClick(appSectionThree,'sectionTwo')">
Previous
</a>
<span class="app-question-pagination">Section 3 of 8</span>
<a class="btn btn-secondary buttonSize" (click)="saveAndNextClick(appSectionThree,'sectionFour')">
Next
</a>
</div>
</form>
组件.ts
ngOnInit() {
this.sectionChangeService.listen().subscribe((message: any) => {
if (message.text === 'prvsparentdemosection') {
this.saveAndNextClick(this.pdemographicsSectionFive, 'sectionFour');
}
});
}
Service:
```typescript
import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class SectionChangeService {
private listner = new Subject<any>();
change(message: string) {
this.listner.next({ text: message });
}
clearListner() {
this.listner.next();
}
listen(): Observable<any> {
return this.listner.asObservable();
}
}