Skip to content

Commit 7be364b

Browse files
committed
fix(ng2 blueprint): register provider on root component
It's best practice to configure providers on the root component rather than with bootstrap.
1 parent e122062 commit 7be364b

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import {bootstrap} from 'angular2/platform/browser';
22
import {<%= jsComponentName %>App} from './app/<%= htmlComponentName %>';
3-
import {ROUTER_PROVIDERS} from 'angular2/router';
43

5-
bootstrap(<%= jsComponentName %>App, [
6-
ROUTER_PROVIDERS
7-
]);
4+
bootstrap(<%= jsComponentName %>App, []);

addon/ng2/blueprints/ng2/files/src/app/__name__.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {Component} from 'angular2/core';
2-
import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
2+
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from 'angular2/router';
33

44

55
@Component({
66
selector: '<%= htmlComponentName %>-app',
7-
providers: [],
7+
providers: [ROUTER_PROVIDERS],
88
templateUrl: 'app/<%= htmlComponentName %>.html',
99
directives: [ROUTER_DIRECTIVES],
1010
pipes: []
@@ -14,7 +14,7 @@ import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';
1414
])
1515
export class <%= jsComponentName %>App {
1616
defaultMeaning: number = 42;
17-
17+
1818
meaningOfLife(meaning?: number) {
1919
return `The meaning of life is ${meaning || this.defaultMeaning}`;
2020
}

0 commit comments

Comments
 (0)