Skip to content

Instantly share code, notes, and snippets.

@petyosi
Created February 9, 2018 13:40
Show Gist options
  • Save petyosi/8186264f26b412b6983d5e6e8ac194c2 to your computer and use it in GitHub Desktop.
Save petyosi/8186264f26b412b6983d5e6e8ac194c2 to your computer and use it in GitHub Desktop.
import {Component} from "@angular/core";
@Component({
selector: 'my-app',
template: `
Hello {{ name }}
<hr/>
<squared-value [value]="4"></squared-value>
<cubed-value [value]="4"></cubed-value>
<quadrupal-value [value]="4"></quadrupal-value>
<hr>
<simple-1-value></simple-1-value>
<simple-2-value></simple-2-value>
<simple-3-value></simple-3-value>
<simple-4-value></simple-4-value>
<simple-5-value></simple-5-value>
<simple-6-value></simple-6-value>
`
})
export class AppComponent {
name: string = "Sean";
constructor() {
}
}
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {enableProdMode} from "@angular/core";
import {AppModule} from "./app.module";
declare var process;
if (process.env.ENV === 'production') {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
// app.module.ts
import {NgModule} from "@angular/core";
import {BrowserModule} from "@angular/platform-browser";
// application
import {AppComponent} from "./app.component";
import {SquareComponent} from "./components/square.component";
import {CubeComponent} from "./components/cube.component";
import {QuadComponent} from "./components/quad.component";
@NgModule({
imports: [
BrowserModule
],
declarations: [
AppComponent,
SquareComponent,
CubeComponent,
QuadComponent
],
bootstrap: [AppComponent]
})
export class AppModule {
}
import {Component, Input} from '@angular/core';
@Component({
selector: 'cubed-value',
template: `{{valueCubed()}}`
})
export class CubeComponent {
@Input() value: number;
public valueCubed(): number {
return this.value * this.value * this.value;
}
}
import {Component, Input} from '@angular/core';
@Component({
selector: 'quadrupal-value',
template: `{{valueQuadrupaled()}}`
})
export class QuadComponent {
@Input() value: number;
public valueQuadrupaled(): number {
return this.value * this.value * this.value * this.value;
}
}
// ...repeated 6 times
import {Component, Input} from '@angular/core';
@Component({
selector: 'simple-1-value',
template: `{{ value }}`
})
export class Simple1Component {
@Input() value: number = 1;
}
import {Component, Input} from '@angular/core';
@Component({
selector: 'squared-value',
template: `{{valueSquared()}}`
})
export class SquareComponent {
@Input() value: number;
public valueSquared(): number {
return this.value * this.value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment