web-dave / angular-elements

1 stars 0 forks source link

Angular Elements Generate a Component #3

Open web-dave opened 6 years ago

web-dave commented 6 years ago

ng g component moin --inline-style --inline-template -v ShadowDom
web-dave commented 6 years ago

import {
  Component,
  OnChanges,
  ViewEncapsulation,
  Input,
  Output,
  EventEmitter
} from "@angular/core";

@Component({
  selector: "moin-moin",
  template: `
    <p>
      moin {{name}}!
    </p>
    <button (click)="hi()">^5</button>
  `,
  styles: [],
  encapsulation: ViewEncapsulation.ShadowDom
})
export class MoinComponent implements OnChanges {
  @Input() name: string;
  @Output() highFive = new EventEmitter<string>();
  constructor() {}

  ngOnChanges(obj) {
    console.warn(obj);
  }

  hi() {
    this.highFive.emit(`Hi! I'm ${this.name}!`);
  }
}
web-dave commented 5 years ago

NEXT