</div>
<br/><br/>
+<div>
+ <h4>Cross-tab communications example</h4>
+ <p>To test, open this sandbox in a second browser tab. Enter something in the input box below, then switch to the other tab and click anywhere on the page.
+ You should see the message that you sent to the other browser tab.</p>
+</div>
+<div class="row">
+ <div class="col-lg-3">
+ <input type="text" #sendSbMessage placeholder="message to send to another tab" size="40" (change)="sendMessage($event)">
+ </div>
+ <div class="col-lg-3">
+ message received: {{sbChannelText}}
+ </div>
+</div>
+
<!-- grid stuff -->
<ng-template #cellTmpl let-row="row" let-col="col" let-userContext="userContext">
HELLO {{userContext.hello}}
// selector field value on metarecord object
aMetarecord: string;
+ // cross-tab communications example
+ private sbChannel: any;
+ sbChannelText: string;
+
constructor(
private idl: IdlService,
private org: OrgService,
private format: FormatService,
private printer: PrintService
) {
+ // BroadcastChannel is not yet defined in PhantomJS and elsewhere
+ this.sbChannel = (typeof BroadcastChannel === 'undefined') ?
+ {} : new BroadcastChannel('eg.sbChannel');
+ this.sbChannel.onmessage = (e) => this.sbChannelHandler(e);
}
ngOnInit() {
});
}
+ sbChannelHandler = msg => {
+ setTimeout(() => { this.sbChannelText = msg.data.msg; });
+ }
+
+ sendMessage($event) {
+ this.sbChannel.postMessage({msg : $event.target.value});
+ }
+
openEditor() {
this.fmRecordEditor.open({size: 'lg'}).then(
ok => { console.debug(ok); },