Skip to content

Instantly share code, notes, and snippets.

@LironHazan
Created October 5, 2019 18:11
Show Gist options
  • Save LironHazan/f61b47c395a5d78493f68623eb539cb3 to your computer and use it in GitHub Desktop.
Save LironHazan/f61b47c395a5d78493f68623eb539cb3 to your computer and use it in GitHub Desktop.
silly-btn.ts
import {Component, Input, OnInit, ViewEncapsulation} from '@angular/core';
import {SillyButtonService} from './silly-button.service';
@Component({
// tslint:disable-next-line:component-selector
selector: 'ng-silly-button',
template:
`<div class="silly-btn" (click)="onClick($event)">
<div class="content">
<ng-content></ng-content>
</div>
<button class="content" mat-button> {{ text }} </button>
</div>`,
styleUrls: ['./silly-button.component.css'],
encapsulation: ViewEncapsulation.ShadowDom
})
export class SillyButtonComponent implements OnInit {
@Input() text = 'Hell Yeahh!';
constructor(private sillyButtonService: SillyButtonService) { }
ngOnInit() {
console.log('connected callback');
}
onClick(evt) {
this.sillyButtonService.doSomething('foo');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment