Angular2 Safari Return Button

In actual Angular2 beta 14 (and earlier), there seems to be a problem with the back button (when using routing and multiple views) in Safari (actually using 9.1): https://github.com/angular/angular/issues / 7722

I also experienced this problem while it is working fine, for example. on Chrome.

Am I looking for a workaround until the problem is fixed?

+6
source share
3 answers

In "angular2": "2.0.0-beta.14"

I needed to run a tick in the zone to make it work for me.

import {ApplicationRef, <anything else you need>} from 'angular2/core'; import {Router,<anything else you need>} from 'angular2/router'; export class AppComponent { constructor(private _ref: ApplicationRef, private _router: Router) { _router.subscribe((value) => { _ref.zone.run(() => _ref.tick()); }); } } 
+5
source

There is a partial workaround for this error:

  • Entering Router and ApplicationRef in an ApplicationRef Component
  • Subscribe to router changes and check the complete component:
  router.subscribe((value)=> { //todo: check browser UA or any other parameters to detect back button, ie if (safari) {} //trigger change that will invoke init methods appRef.tick(); }); 
+2
source

angular2 - 2.15.8

 constructor(private _ref: ApplicationRef, private _router: Router) { _router.events.subscribe((value) => { _ref.zone.run(() => _ref.tick()); }); } 

Using _router.subscribe is deprecated and will call the Undefined .subscribe () function on _router.

0
source

All Articles