Skip to content

Commit 5514f81

Browse files
committed
feat(blueprints router): add the router
1 parent ba4f81b commit 5514f81

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed
+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
import {provide} from 'angular2/core';
12
import {bootstrap} from 'angular2/platform/browser';
3+
import {
4+
ROUTER_PROVIDERS,
5+
HashLocationStrategy,
6+
LocationStrategy
7+
} from 'angular2/router';
8+
9+
210
import {<%= jsComponentName %>App} from './app/<%= htmlComponentName %>';
311

412

5-
bootstrap(<%= jsComponentName %>App);
13+
bootstrap(<%= jsComponentName %>App, [
14+
ROUTER_PROVIDERS, provide(LocationStrategy, { useClass: HashLocationStrategy })]);
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<p>
22
<%= htmlComponentName %> Works!
3-
</p>
3+
</p>
4+
5+
<router-outlet></router-outlet>

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
import {Component} from 'angular2/core';
2+
import {
3+
RouteConfig,
4+
Route,
5+
ROUTER_DIRECTIVES
6+
} from 'angular2/router';
27

8+
import {HelloCmp} from './components/hello/hello';
39

410
@Component({
511
selector: '<%= htmlComponentName %>-app',
612
providers: [],
713
templateUrl: 'app/<%= htmlComponentName %>.html',
8-
directives: [],
14+
directives: [ROUTER_DIRECTIVES],
915
pipes: []
1016
})
17+
@RouteConfig([
18+
new Route({ path: '/', component: HelloCmp, name: 'HelloCmp' }),
19+
])
1120
export class <%= jsComponentName %>App {
1221
defaultMeaning: number = 42;
1322

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>Hello works!</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {Component} from 'angular2/core';
2+
3+
@Component({
4+
selector: 'hello-cmp',
5+
templateUrl: 'app/components/hello/hello.html'
6+
})
7+
export class HelloCmp {
8+
9+
}

0 commit comments

Comments
 (0)