Skip to content

Instantly share code, notes, and snippets.

@krawaller
Created July 25, 2017 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krawaller/73f17bee49f34cac8e7ec1138c9ba4ca to your computer and use it in GitHub Desktop.
Save krawaller/73f17bee49f34cac8e7ec1138c9ba4ca to your computer and use it in GitHub Desktop.
Angular components as table rows
import { Component, Input } from '@angular/core';
@Component({
selector: 'app',
template: `
<table>
<tr magicrow msg="hello"></tr>
<tr magicrow msg="world"></tr>
</table>
`,
})
export class AppComponent {}
@Component({
selector: 'tr[magicrow]',
template: `
<td>{{msg}}</td>
`
})
export class RowComponent {
@Input() msg: string
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppComponent, RowComponent } from './components';
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent, RowComponent ],
bootstrap: [ AppComponent ]
})
class AppModule {}
platformBrowserDynamic().bootstrapModule(AppModule);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment