Skip to content

Commit 4ad6899

Browse files
committed
feat(blueprints router): add the router
1 parent 563e6e2 commit 4ad6899

File tree

6 files changed

+34
-3
lines changed

6 files changed

+34
-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+
}

addon/ng2/blueprints/ng2/files/src/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<base href=".">
66
<script src="vendor/systemjs/dist/system.src.js"></script>
77
<script src="vendor/angular2/bundles/angular2.dev.js"></script>
8+
<script src="vendor/angular2/bundles/router.dev.js"></script>
89
{{content-for 'head'}}
910
<script>
1011
System.config({

0 commit comments

Comments
 (0)