Created
          July 25, 2017 14:31 
        
      - 
      
- 
        Save krawaller/73f17bee49f34cac8e7ec1138c9ba4ca to your computer and use it in GitHub Desktop. 
    Angular components as table rows
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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 | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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