Created
February 7, 2017 17:32
-
-
Save tolemac/cb3f262a4efe967d5e2886f3fee3ce54 to your computer and use it in GitHub Desktop.
Angular 2 Visual Inheritance
This file contains 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} from '@angular/core'; | |
function GridComponent(obj: any) { | |
let templateMetadata = { | |
template: `blablablab | |
<table> | |
<thead> | |
<tr>${obj.headerTemplate}</tr> | |
</thead> | |
<tbody> | |
<tr *ngFor="let obj of list">${obj.rowTemplate}</tr> | |
</tbody> | |
</table> | |
blablabla` | |
} | |
return Component(Object.Assign(obj, templateMetadata)); | |
} | |
class GridComponentBase { | |
// ... | |
// ... | |
// ... | |
} |
This file contains 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 {GridComponent, GridComponentBase} from './GridComponent'; | |
@GridComponent({ | |
selector: 'person-grid', | |
headerTemplate: '<th>Nombre</th><th>Apellidos</th>', | |
rowTemplate: '<td>obj.name</td><td>obj.surname</td>' | |
}) | |
class PersonGridComponent extends GridComponentBase { | |
// ... | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment