forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
208 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import {bootstrap} from 'angular2/platform/browser'; | ||
import {<%= jsComponentName %>App} from './app/<%= htmlComponentName %>'; | ||
import {ROUTER_PROVIDERS} from 'angular2/router'; | ||
|
||
|
||
bootstrap(<%= jsComponentName %>App); | ||
bootstrap(<%= jsComponentName %>App, [ | ||
ROUTER_PROVIDERS | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<p> | ||
<%= htmlComponentName %> Works! | ||
</p> | ||
</p> | ||
|
||
<router-outlet></router-outlet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
13 changes: 13 additions & 0 deletions
13
addon/ng2/blueprints/route/files/src/app/__name__/__name__-detail.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div *ngIf="<%= camelizedModuleName %>"> | ||
<h3>"{{editName}}"</h3> | ||
<div> | ||
<label>Id:</label> | ||
{{<%= camelizedModuleName %>.id}} | ||
</div> | ||
<div> | ||
<label>Name:</label> | ||
<input [(ngModel)]="editName" placeholder="name"/> | ||
</div> | ||
<button (click)="save()">Save</button> | ||
<button (click)="cancel()">Cancel</button> | ||
</div> |
54 changes: 54 additions & 0 deletions
54
addon/ng2/blueprints/route/files/src/app/__name__/__name__-detail.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import {Component, OnInit} from 'angular2/core'; | ||
import {<%= classifiedModuleName %>, <%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service'; | ||
import {RouteParams, Router} from 'angular2/router'; | ||
import {CanDeactivate, ComponentInstruction} from 'angular2/router'; | ||
|
||
@Component({ | ||
templateUrl: 'app/<%= dasherizedModuleName %>/<%= dasherizedModuleName %>-detail.component.html', | ||
styleUrls: ['app/<%= dasherizedModuleName %>/<%= dasherizedModuleName %>-detail.component.css'] | ||
}) | ||
export class <%= classifiedModuleName %>DetailComponent implements OnInit, CanDeactivate { | ||
|
||
<%= camelizedModuleName %>: <%= classifiedModuleName %>; | ||
editName: string; | ||
|
||
constructor( | ||
private _service: <%= classifiedModuleName %>Service, | ||
private _router: Router, | ||
private _routeParams: RouteParams | ||
) { } | ||
|
||
ngOnInit() { | ||
let id = +this._routeParams.get('id'); | ||
this._service.get(id).then(<%= camelizedModuleName %> => { | ||
if (<%= camelizedModuleName %>) { | ||
this.editName = <%= camelizedModuleName %>.name; | ||
this.<%= camelizedModuleName %> = <%= camelizedModuleName %>; | ||
} else { | ||
this.gotoList(); | ||
} | ||
}); | ||
} | ||
|
||
routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction): any { | ||
if (!this.<%= camelizedModuleName %> || this.<%= camelizedModuleName %>.name === this.editName) { | ||
return true; | ||
} | ||
|
||
return new Promise<boolean>((resolve, reject) => resolve(window.confirm('Discard changes?'))); | ||
} | ||
|
||
cancel() { | ||
this.editName = this.<%= camelizedModuleName %>.name; | ||
this.gotoList(); | ||
} | ||
|
||
save() { | ||
this.<%= camelizedModuleName %>.name = this.editName; | ||
this.gotoList(); | ||
} | ||
|
||
gotoList() { | ||
this._router.navigate(['<%= classifiedModuleName %>List']); | ||
} | ||
} |
Empty file.
12 changes: 12 additions & 0 deletions
12
addon/ng2/blueprints/route/files/src/app/__name__/__name__-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<h2><%= classifiedModuleName %> List</h2> | ||
|
||
<ul> | ||
<li *ngFor="#<%= camelizedModuleName %> of <%= camelizedModuleName %>s"> | ||
<a | ||
[routerLink]="['<%= classifiedModuleName %>Detail', { id: <%= camelizedModuleName %>.id }]"> | ||
<strong>{{<%= camelizedModuleName %>.id}}</strong> | ||
- | ||
{{<%= camelizedModuleName %>.name}} | ||
</a> | ||
</li> | ||
</ul> |
17 changes: 17 additions & 0 deletions
17
addon/ng2/blueprints/route/files/src/app/__name__/__name__-list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {Component, OnInit} from 'angular2/core'; | ||
import {<%= classifiedModuleName %>, <%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service'; | ||
import {ROUTER_DIRECTIVES} from 'angular2/router'; | ||
|
||
@Component({ | ||
templateUrl: 'app/<%= dasherizedModuleName %>/<%= dasherizedModuleName %>-list.component.html', | ||
styleUrls: ['app/<%= dasherizedModuleName %>/<%= dasherizedModuleName %>-list.component.css'], | ||
directives: [ROUTER_DIRECTIVES] | ||
}) | ||
export class <%= classifiedModuleName %>ListComponent implements OnInit { | ||
<%= camelizedModuleName %>s: <%= classifiedModuleName %>[]; | ||
constructor( | ||
private _service: <%= classifiedModuleName %>Service) {} | ||
ngOnInit() { | ||
this._service.getAll().then(<%= camelizedModuleName %>s => this.<%= camelizedModuleName %>s = <%= camelizedModuleName %>s); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
addon/ng2/blueprints/route/files/src/app/__name__/__name__-root.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Component} from 'angular2/core'; | ||
import {RouteConfig, RouterOutlet} from 'angular2/router'; | ||
|
||
import {<%= classifiedModuleName %>ListComponent} from './<%= dasherizedModuleName %>-list.component'; | ||
import {<%= classifiedModuleName %>DetailComponent} from './<%= dasherizedModuleName %>-detail.component'; | ||
import {<%= classifiedModuleName %>Service} from './<%= dasherizedModuleName %>.service'; | ||
|
||
@Component({ | ||
template: '<router-outlet></router-outlet>', | ||
providers: [<%= classifiedModuleName %>Service], | ||
directives: [RouterOutlet] | ||
}) | ||
@RouteConfig([ | ||
{path:'/', name: '<%= classifiedModuleName %>List', component: <%= classifiedModuleName %>ListComponent, useAsDefault: true}, | ||
{path:'/:id', name: '<%= classifiedModuleName %>Detail', component: <%= classifiedModuleName %>DetailComponent} | ||
]) | ||
export class <%= classifiedModuleName %>Root { | ||
constructor() {} | ||
} |
21 changes: 21 additions & 0 deletions
21
addon/ng2/blueprints/route/files/src/app/__name__/__name__.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {Injectable} from 'angular2/core'; | ||
|
||
export class <%= classifiedModuleName %> { | ||
constructor(public id: number, public name: string) { } | ||
} | ||
|
||
@Injectable() | ||
export class <%= classifiedModuleName %>Service { | ||
getAll() { return promise; } | ||
get(id: number) { | ||
return promise.then(all => all.find(e => e.id === id)); | ||
} | ||
} | ||
|
||
let mock = [ | ||
new <%= classifiedModuleName %>(1, 'one'), | ||
new <%= classifiedModuleName %>(2, 'two'), | ||
new <%= classifiedModuleName %>(3, 'three') | ||
]; | ||
|
||
let promise = Promise.resolve(mock); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var stringUtils = require('ember-cli/lib/utilities/string'); | ||
|
||
module.exports = { | ||
description: '' | ||
|
||
//locals: function(options) { | ||
// // Return custom template variables here. | ||
// return { | ||
// | ||
// }; | ||
//} | ||
|
||
// afterInstall: function(options) { | ||
// // Perform extra work here. | ||
// } | ||
}; |