一些服务:
public validateItemAgainstServer = (item: EspApplication) => {
...
window.localStorage.setItem('item', "|")
...
});
}
组件
constructor(private winRef: WindowRef) {
winRef.nativeWindow.addEventListener('storage', function (e) {
console.log("storage event occured");
}, false);
window.addEventListener('storage', function (e) {
console.log("storage event occured");
}, false);
}
WinRef公司
import { Injectable } from '@angular/core';
function _window(): any {
// return the global native browser window object
return window;
}
@Injectable()
export class WindowRef {
get nativeWindow(): any {
return _window();
}
}
遗憾的是,存储事件没有被触发。有没有可能解决这个问题,或者可能有一些更好的想法,如何同步两个标签在角度?