Angular 2: Difference between revisions

add a block about variable
add a typescript block
add a block about variable
Line 18: Line 18:
TypeScript app.ts. import {bootstrap}, and {bootstrap} is called ''destructuring''.
TypeScript app.ts. import {bootstrap}, and {bootstrap} is called ''destructuring''.


<syntaxhighlight lang="typescript">
<syntaxhighlight lang="javascript">
/// <reference path="node_modules/anguar2/ts/typings/node/node.d.ts"/>
/// <reference path="node_modules/anguar2/ts/typings/node/node.d.ts"/>
/// <reference path="node_modules/anguar2/typings/browser.d.ts"/>
/// <reference path="node_modules/anguar2/typings/browser.d.ts"/>
Line 34: Line 34:


class HelloWorld {
class HelloWorld {
}
bootstrap(HelloWorld);
</syntaxhighlight>
Adding a variable.
<syntaxhighlight lang="javascript">
/// <reference path="node_modules/anguar2/ts/typings/node/node.d.ts"/>
/// <reference path="node_modules/anguar2/typings/browser.d.ts"/>
import {bootstrap} from "angular2/platform/browser";
import {Component} from "angular2/core";
@Component({
    selector: 'hello-world',
    template: `<div>Hello, {{name}}</div>`
})
class HelloWorld {
    name: string;
    constructor() {
        this.name = 'Felipe';
    }
}
}


bootstrap(HelloWorld);
bootstrap(HelloWorld);
</syntaxhighlight>
</syntaxhighlight>