From 5514f8143f6314265230d25d42a7f48347a2c2b0 Mon Sep 17 00:00:00 2001
From: Ciro Nunes
Date: Thu, 10 Dec 2015 13:00:22 -0200
Subject: [PATCH] feat(blueprints router): add the router
---
addon/ng2/blueprints/ng2/files/src/app.ts | 11 ++++++++++-
addon/ng2/blueprints/ng2/files/src/app/__name__.html | 4 +++-
addon/ng2/blueprints/ng2/files/src/app/__name__.ts | 11 ++++++++++-
.../ng2/files/src/app/components/hello/hello.html | 1 +
.../ng2/files/src/app/components/hello/hello.ts | 9 +++++++++
5 files changed, 33 insertions(+), 3 deletions(-)
create mode 100644 addon/ng2/blueprints/ng2/files/src/app/components/hello/hello.html
create mode 100644 addon/ng2/blueprints/ng2/files/src/app/components/hello/hello.ts
diff --git a/addon/ng2/blueprints/ng2/files/src/app.ts b/addon/ng2/blueprints/ng2/files/src/app.ts
index f752e09bdcc8..53b2cdfe9f4a 100644
--- a/addon/ng2/blueprints/ng2/files/src/app.ts
+++ b/addon/ng2/blueprints/ng2/files/src/app.ts
@@ -1,5 +1,14 @@
+import {provide} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
+import {
+ ROUTER_PROVIDERS,
+ HashLocationStrategy,
+ LocationStrategy
+} from 'angular2/router';
+
+
import {<%= jsComponentName %>App} from './app/<%= htmlComponentName %>';
-bootstrap(<%= jsComponentName %>App);
+bootstrap(<%= jsComponentName %>App, [
+ ROUTER_PROVIDERS, provide(LocationStrategy, { useClass: HashLocationStrategy })]);
diff --git a/addon/ng2/blueprints/ng2/files/src/app/__name__.html b/addon/ng2/blueprints/ng2/files/src/app/__name__.html
index f206e8e44c93..07f981887829 100644
--- a/addon/ng2/blueprints/ng2/files/src/app/__name__.html
+++ b/addon/ng2/blueprints/ng2/files/src/app/__name__.html
@@ -1,3 +1,5 @@
<%= htmlComponentName %> Works!
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/addon/ng2/blueprints/ng2/files/src/app/__name__.ts b/addon/ng2/blueprints/ng2/files/src/app/__name__.ts
index 86601ac047f9..d8431a4af5b6 100644
--- a/addon/ng2/blueprints/ng2/files/src/app/__name__.ts
+++ b/addon/ng2/blueprints/ng2/files/src/app/__name__.ts
@@ -1,13 +1,22 @@
import {Component} from 'angular2/core';
+import {
+ RouteConfig,
+ Route,
+ ROUTER_DIRECTIVES
+} from 'angular2/router';
+import {HelloCmp} from './components/hello/hello';
@Component({
selector: '<%= htmlComponentName %>-app',
providers: [],
templateUrl: 'app/<%= htmlComponentName %>.html',
- directives: [],
+ directives: [ROUTER_DIRECTIVES],
pipes: []
})
+@RouteConfig([
+ new Route({ path: '/', component: HelloCmp, name: 'HelloCmp' }),
+])
export class <%= jsComponentName %>App {
defaultMeaning: number = 42;
diff --git a/addon/ng2/blueprints/ng2/files/src/app/components/hello/hello.html b/addon/ng2/blueprints/ng2/files/src/app/components/hello/hello.html
new file mode 100644
index 000000000000..7b7d7fb15fee
--- /dev/null
+++ b/addon/ng2/blueprints/ng2/files/src/app/components/hello/hello.html
@@ -0,0 +1 @@
+Hello works!
\ No newline at end of file
diff --git a/addon/ng2/blueprints/ng2/files/src/app/components/hello/hello.ts b/addon/ng2/blueprints/ng2/files/src/app/components/hello/hello.ts
new file mode 100644
index 000000000000..7b73cc80a7ea
--- /dev/null
+++ b/addon/ng2/blueprints/ng2/files/src/app/components/hello/hello.ts
@@ -0,0 +1,9 @@
+import {Component} from 'angular2/core';
+
+@Component({
+ selector: 'hello-cmp',
+ templateUrl: 'app/components/hello/hello.html'
+})
+export class HelloCmp {
+
+}
\ No newline at end of file