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
@Component({ | |
selector: 'my-app', | |
template: ` | |
<div class="container-fluid"> | |
<div class="page-header"> | |
<h1>Creating AOT Friendly Dynamic Components with Angular 2</h1> | |
</div> | |
<div class="row"> | |
<div class="col-lg-12"> | |
<div class="panel panel-default"> |
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
@NgModule({ | |
imports: [ | |
BrowserModule, | |
FormsModule, | |
GridModule.withComponents([ | |
BlueDynamicComponent, | |
GreenDynamicComponent, | |
RedDynamicComponent | |
]) | |
], |
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
@NgModule({ | |
imports: [ | |
BrowserModule, | |
FormsModule | |
], | |
declarations: [ | |
Grid, | |
Cell | |
], | |
exports: [ |
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
@Component({ | |
selector: 'grid-cell', | |
template: '' | |
}) | |
export class Cell implements OnInit { | |
@Input() componentType: any; | |
constructor(private viewContainerRef: ViewContainerRef, | |
private cfr: ComponentFactoryResolver) { | |
} | |
ngOnInit() { |
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
@Component({ | |
selector: 'grid-component', | |
template: ` | |
<div class="row" *ngFor="let cellComponentType of cellComponentTypes"> | |
<<div class="col-lg-12"> | |
<grid-cell [componentType]="cellComponentType"></grid-cell> | |
</div> | |
</div> | |
` | |
}) |
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
const path = require('path'); | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
path: path.resolve(__dirname, './dist/'), | |
filename: 'bundle.js', | |
publicPath: 'dist/' | |
}, | |
module: { |
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 multiply from './multiply'; | |
import sum from './sum'; | |
// import our image utility | |
import addImageToPage from './image_util'; | |
// import the images we want to use | |
import multiplyImg from '../images/multiply.png'; | |
import sumImg from '../images/sum.png'; |
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
const addImageToPage = (imageSrc) => { | |
const image = document.createElement('img'); | |
image.src = imageSrc; | |
image.style.height = '100px'; | |
image.style.width = '100px'; | |
document.body.appendChild(image); | |
}; | |
export default addImageToPage; |
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
const path = require('path'); | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
path: path.resolve(__dirname, './dist/'), | |
filename: 'bundle.js' | |
}, | |
module: { | |
loaders: [ |
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
const path = require('path'); | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
path: path.resolve(__dirname, './dist/'), | |
filename: 'bundle.js' | |
}, | |
module: { | |
loaders: [ | |
{ |