【发布时间】:2020-03-17 21:25:35
【问题描述】:
我有两个 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();
}
}
【问题讨论】:
-
您是否在浏览器控制台中看到任何错误或警告?如果是,请让我们知道该错误。它可以帮助缩小问题范围。
-
@Deepak-MSFT 我在控制台中看不到任何内容,没有错误
-
您的项目是在 IE 11 中运行还是显示空白页?我可以在代码中看到箭头函数。那么你是否添加了必要的 polyfill 或使用 Babel 来转译代码?
标签: javascript angular internet-explorer rxjs rxjs-observables