本文整理匯總了TypeScript中angular2/angular2.bootstrap函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript bootstrap函數的具體用法?TypeScript bootstrap怎麽用?TypeScript bootstrap使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了bootstrap函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: bootstrap
import {bootstrap} from 'angular2/angular2';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http';
import {App} from './components/app/app';
import {BaseService} from './components/baseServices/base.service';
import {ViewbagService} from './components/viewbag/viewbag.service';
bootstrap(App, [
ROUTER_PROVIDERS, HTTP_PROVIDERS, BaseService, ViewbagService
]);
示例2: bootstrap
import {bootstrap, Component} from "angular2/angular2";
import {TodoInput} from "./todoInput";
import {TodoService} from "./todoService";
import {TodoList} from "./todoList";
@Component({
selector:'app',
directives: [TodoInput, TodoList],
template: `
<div>
<todo-input></todo-input>
<todo-list></todo-list>
</div>
`
})
class App{}
bootstrap(App, [TodoService]);
示例3: constructor
this.checked = false;
}
}
class TodoList {
items: Todo[];
constructor() {
this.items = [];
};
remove(item) {
var idx = this.items.indexOf(item);
this.items.splice(idx, 1);
};
add(item) {
if (!this.containsByName(item)) {
this.items.push(item);
}
};
containsByName(item) {
for (var i = 0; i < this.items.length; ++i) {
if (this.items[i].name == item.name) {
return true;
}
}
return false;
}
}
bootstrap(TodoAppComponent);
示例4: constructor
/// <reference path="typings/angular2/angular2.d.ts" />
import {Component, View, bootstrap} from 'angular2/angular2';
import{DemoPage} from './demo-page';
@Component({
selector: 'demo-app'
})
@View({
template: '<demo-page></demo-page>',
directives:[DemoPage]
})
class MyDemoApp {
constructor() {
}
}
bootstrap(MyDemoApp);
示例5: bootstrap
// #docregion
// #docregion import
import {Component, View, bootstrap} from 'angular2/angular2';
// #enddocregion
@Component({
selector: 'my-app'
})
@View({
template: '<h1 id="output">My first Angular 2 App</h1>'
})
class AppComponent {
}
// #docregion bootstrap
bootstrap(AppComponent);
// #enddocregion
示例6: constructor
import {Dashboard} from './components/dashboard/dashboard';
import {Login} from './components/login/login';
@Component({
selector: 'app'
})
@View({
directives: [ RouterOutlet, RouterLink ],
template: `
<a router-link="base">base</a>
<a router-link="dashboard">dashboard</a>
<a router-link="login">login</a>
<br>
<router-outlet></router-outlet>
`
})
@RouteConfig([
{ path: '/', component: Base, as: 'base' },
{ path: '/dashboard', component: Dashboard, as: 'dashboard' },
{ path: '/login', component: Login, as: 'login' },
])
class App {
userid: string;
password: string;
constructor() {
}
}
bootstrap(App, [routerInjectables]);
示例7: constructor
/// <reference path="../typings/tsd.d.ts" />
import {Component, View, bootstrap} from 'angular2/angular2';
import {LastFMEvents} from 'components/lastfm/events/component'
import {InstagramPictures} from 'components/instagram/pictures/component'
import {InstagramPicture} from 'components/instagram/picture/component'
@Component({
selector: 'app'
})
@View({
templateUrl: 'app.html',
directives: [LastFMEvents, InstagramPictures]
})
class App {
public pictures: Array<InstagramPicture>
constructor() {}
}
bootstrap(App);
示例8: constructor
/* Contenedor principal */
@Component({
selector: 'game',
injectables: [PlayerComponent,TileService]
})
@View({
template: `
<h1>Multi-user Memory Game!!</h1>
<div id="gameContainer">
<div id="playerContainer1">
<player>
</player>
</div>
<div id="playerContainer2">
<player>
</player>
</div>
</div>
`,
directives: [PlayerComponent]
})
export class GameComponent {
player1: PlayerComponent;
player2: PlayerComponent;
constructor(player1:PlayerComponent,player2:PlayerComponent){
this.player1 = player1;
this.player2 = player2;
}
}
bootstrap(GameComponent);
示例9: constructor
template: `
<div class="row">
<div class="col-md-12">
<new-genre-form />
</div>
</div>
<tabs>
<tab *ng-for="#genre of genres" [tab-title]="genre.name + ' (' + genre.artistCount + ')'">
<music-genre [genre]="genre"></music-genre>
</tab>
</tabs>
`,
directives: [TabsComponent, TabComponent, NgFor, MusicGenreComponent, NewGenreFormComponent]
})
class MusicBrowserComponent {
genres:Array<MusicGenre>;
constructor(musicGenreService: MusicGenreService) {
this.genres = musicGenreService.genres;
}
activateGenre(genre: MusicGenre){
this.genres.forEach(genre => genre.isActive = false);
genre.isActive = true;
return false;
}
}
bootstrap(MusicBrowserComponent);
示例10: bootstrap
/// <reference path="typings/tsd.d.ts" />
import {bootstrap} from 'angular2/angular2';
import {Todo} from 'components/todo';
bootstrap(Todo);