Skip to content

Instantly share code, notes, and snippets.

@hetdev
Created August 27, 2019 16:57
Show Gist options
  • Save hetdev/58a8bfa1412cfe4fa9ef598201f9339e to your computer and use it in GitHub Desktop.
Save hetdev/58a8bfa1412cfe4fa9ef598201f9339e to your computer and use it in GitHub Desktop.
import {Component, Input, OnChanges, OnDestroy, OnInit, SimpleChange} from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit, OnChanges, OnDestroy {
title = 'phoenix-wc-wiki-ngx-lt';
@Input() token: string;
constructor() {
console.log('token constructor=' + this.token);
}
ngOnInit() {
console.log('token ngOnInit=' + this.token);
window.addEventListener('phoenix-wc-wiki-ngx-ce-data-sent-test', this.customEventListenerFunction, true);
}
customEventListenerFunction(event) {
console.log('testfunc - ' , event.detail);
}
ngOnChanges(changes: {[token: string]: SimpleChange}) {
// check the object "changes" for new data
console.log('token ngOnChanges=' + this.token);
}
ngOnDestroy(): void {
window.removeEventListener('changeNameToCustomEvent', this.customEventListenerFunction, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment