-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
116 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import * as angular from 'angular'; | ||
import 'angular-route' | ||
import {NgModule} from '@angular/core'; | ||
import {UpgradeAdapter} from '@angular/upgrade'; | ||
|
||
import {MenuCmp} from './menu_cmp'; | ||
|
||
export const MenuModule = angular.module('MenuModule', ['ngRoute']); | ||
|
||
MenuModule.component('menu', { | ||
template : ` | ||
<h1>Messages</h1> | ||
<ul> | ||
<li><a href="#/messages/inbox">Inbox</a></li> | ||
<li><a href="#/settings">Settings</a></li> | ||
</ul> | ||
` | ||
}); | ||
MenuModule.component('menu', MenuCmp); | ||
|
||
MenuModule.config(($routeProvider) => { | ||
$routeProvider | ||
.when('/', {template : '<menu></menu>'}); | ||
}); | ||
$routeProvider.when('/', {template : '<menu></menu>'}); | ||
}); | ||
|
||
@NgModule({}) | ||
export class MenuNgModule { | ||
static setAdapter(adapter: UpgradeAdapter) { | ||
//no components are migrated to angular2 | ||
} | ||
} |
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,9 @@ | ||
export const MenuCmp = { | ||
template : ` | ||
<h1>Messages</h1> | ||
<ul> | ||
<li><a href="#/messages/inbox">Inbox</a></li> | ||
<li><a href="#/settings">Settings</a></li> | ||
</ul> | ||
` | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {Message, Repository} from '../repository'; | ||
|
||
export class MessageController { | ||
folder: string; | ||
id: number; | ||
message: Message; | ||
|
||
constructor($routeParams, repository: Repository) { | ||
this.folder = $routeParams.folder; | ||
this.id = +$routeParams.id; | ||
this.message = repository.message(this.id); | ||
} | ||
} | ||
|
||
export const MessageCmp = { | ||
template : ` | ||
<h1>Message {{ctrl.id}}</h1> | ||
<message-text [text]="ctrl.message.text"></message-text> | ||
<div> | ||
<a href="#/messages/{{ctrl.folder}}">Go to Folder</a> | ||
</div> | ||
`, | ||
controller : MessageController, | ||
controllerAs: 'ctrl' | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {Message, Repository} from '../repository'; | ||
|
||
export class MessagesController { | ||
folder: string; | ||
messages: Message[]; | ||
|
||
constructor($routeParams, repository: Repository) { | ||
this.folder = $routeParams.folder; | ||
this.messages = repository.messagesFor(this.folder); | ||
} | ||
} | ||
|
||
export const MessagesCmp = { | ||
template : ` | ||
<h1>Messages</h1> | ||
<ul> | ||
<li ng-repeat="m in ctrl.messages"> | ||
{{m.id}} - <a href="#/messages/{{ctrl.folder}}/{{m.id}}">{{m.text}}</a> | ||
</li> | ||
</ul> | ||
<a href="#/settings/pagesize">Change Page Size</a> | ||
<a href="#/">Back</a> | ||
`, | ||
controller : MessagesController, | ||
controllerAs: 'ctrl' | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {Component} from '@angular/core'; | ||
import {Repository} from '../repository' | ||
|
||
@Component({ | ||
selector: 'page-settings', | ||
template: ` | ||
<h1>Page Size Settings</h1> | ||
<div *ngFor="let p of repository.folders"> | ||
Page size for '{{p}}' <input [(ngModel)]="repository.pageSize[p]"> (<a [routerLink]="['/messages', p]">open</a>) | ||
</div> | ||
<a routerLink="../">Back</a> | ||
` | ||
}) | ||
export class PageSizeCmp { | ||
constructor(private repository: Repository) {} | ||
} |
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 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'settings', | ||
template: ` | ||
<h1>Settings</h1> | ||
<a routerLink="pagesize">Page Size Settings</a> | ||
<a routerLink="../">Back</a> | ||
` | ||
}) | ||
export class SettingsCmp { | ||
} |