Skip to content

Instantly share code, notes, and snippets.

@Armenvardanyan95
Created June 24, 2017 11:06
Show Gist options
  • Save Armenvardanyan95/b576712188b4065b30c271ed08fe61f8 to your computer and use it in GitHub Desktop.
Save Armenvardanyan95/b576712188b4065b30c271ed08fe61f8 to your computer and use it in GitHub Desktop.
@Component({
selector: 'nested-component',
template: `
<div>
<input id="nestedInput" type="text" (blur)="onBlurMethod()" />
</div>
`
})
class NestedComponent {
@Output() onBlur: EventEmitter<any> = new EventEmitter();
onBlurMethod(){
this.onBlur.emit({'message': 'Hi, this is an event from a nested component'});
}
}
@Component({
selector: 'parent-component',
template: `
<div>
<nested-component (onBlur)="onBlur()"></nested-component>
</div>
`
})
class ParentComponent {
onBlur() {
console.log('The user navigated away from the input box');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment