Skip to content

Commit

Permalink
Update to rc.5
Browse files Browse the repository at this point in the history
  • Loading branch information
vladotesanovic committed Aug 10, 2016
1 parent 0b1acec commit ab35e8b
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 76 deletions.
3 changes: 1 addition & 2 deletions app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ROUTER_DIRECTIVES } from '@angular/router';

@Component({
directives: [ROUTER_DIRECTIVES],
providers: [Location],
selector: 'my-app',
styles: [`h1 {
color: white;
Expand All @@ -21,4 +20,4 @@ export class AppComponent {
name: string = "Angular 2 on Express";

constructor() {}
}
}
21 changes: 21 additions & 0 deletions app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from './app.component';
import { AboutComponent } from "./components/about/about.component";
import { routing } from "./routes";
import { HomeComponent } from "./components/home/home.component";

@NgModule({
imports: [
BrowserModule,
routing
],
declarations: [
AppComponent,
AboutComponent,
HomeComponent
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
4 changes: 2 additions & 2 deletions app/components/home/home.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h2>Page: {{name}}</h2>

<pre>Response from server: /users</pre>
<pre>{{ ( users | async)?.name }}</pre>
<pre>{{ ( users | async)?.last }}</pre>
<pre>{{ users?.name }}</pre>
<pre>{{ users?.last }}</pre>
4 changes: 3 additions & 1 deletion app/components/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export class HomeComponent {
users: {};

constructor(http: Http) {
this.users = http.get("/users").map(data => data.json());
http.get("/users")
.map(data => data.json())
.subscribe((data) => this.users = data);
}
}
12 changes: 5 additions & 7 deletions app/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { bootstrap } from '@angular/platform-browser-dynamic';
import { Type } from '@angular/core';
import { HTTP_PROVIDERS } from "@angular/http";
import { AppComponent } from './app.component'
import { APP_ROUTER_PROVIDERS } from "./routes";

bootstrap(<Type>AppComponent, [
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';

platformBrowserDynamic([
HTTP_PROVIDERS,
APP_ROUTER_PROVIDERS
]);
]).bootstrapModule(AppModule);
22 changes: 5 additions & 17 deletions app/routes.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
import { provideRouter, RouterConfig } from '@angular/router';
import { LocationStrategy, HashLocationStrategy } from "@angular/common";
import { Type } from '@angular/core';

import {ComponentResolver, SystemJsComponentResolver} from '@angular/core';
import {RuntimeCompiler} from '@angular/compiler';
import { Routes, RouterModule } from '@angular/router';

import { HomeComponent } from './components/home/home.component';
import { AboutComponent } from './components/about/about.component';

const routes: RouterConfig = [
{ path: '', component: <Type>HomeComponent, terminal: true },
{ path: 'about', component: <Type>AboutComponent }
export const routes: Routes = [
{ path: '', component: HomeComponent, terminal: true },
{ path: 'about', component: AboutComponent }
];

export const APP_ROUTER_PROVIDERS = [
provideRouter(routes), {
provide: ComponentResolver,
useFactory: (compiler) => new SystemJsComponentResolver(compiler),
deps: [RuntimeCompiler]
},
{ provide: LocationStrategy, useClass: HashLocationStrategy }
];
export const routing = RouterModule.forRoot(routes, { useHash: true });
31 changes: 17 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"tsc:w": "tsc -w",
"typings": "typings install",
"bundle": "node bin/bundler.js",
"bundle:prod": "node bin/bundler.js --prod"
"bundle:prod": "node bin/bundler.js --prod",
"ngc": "ngc -p ."

},
"dependencies": {
"body-parser": "~1.13.2",
Expand All @@ -19,25 +21,26 @@
"serve-favicon": "~2.3.0"
},
"devDependencies": {
"@angular/common": "2.0.0-rc.3",
"@angular/compiler": "2.0.0-rc.3",
"@angular/core": "2.0.0-rc.3",
"@angular/http": "2.0.0-rc.3",
"@angular/platform-browser": "2.0.0-rc.3",
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
"@angular/router": "^3.0.0-alpha.7",
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/forms": "0.3.0",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/router": "3.0.0-rc.1",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.3",
"systemjs": "0.19.27",
"@angular/upgrade": "2.0.0-rc.5",
"angular2-in-memory-web-api": "0.0.15",
"concurrently": "^2.0.0",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"angular2-in-memory-web-api": "0.0.12",
"concurrently": "^2.0.0",
"systemjs": "0.19.27",
"systemjs-builder": "^0.15.17",
"typescript": "^1.8.10",
"typings": "^1.3.0",
"yargs": "^4.7.1"
"yargs": "^4.7.1",
"zone.js": "^0.6.12"
}
}
3 changes: 2 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script src="js/vendor/system.js"></script>
<!--
Development mod
<script src="js/systemjs.config.js"></script>
<script>
System.import('app').catch(function(err) { console.error(err); });
Expand All @@ -24,6 +25,6 @@
<my-app>Loading...</my-app>

<!-- Production mod -->
<script src="js/bundle.min.js"></script>
<<script src="js/bundle.min.js"></script>
</body>
</html>
45 changes: 23 additions & 22 deletions public/js/bundle.min.js

Large diffs are not rendered by default.

11 changes: 3 additions & 8 deletions public/js/systemjs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var isPublic = typeof window != "undefined";
var map = {
'app': (isPublic)? '' : 'app', // 'dist',
'@angular': (isPublic)? '@angular' : 'node_modules/@angular',
'@angular/router': (isPublic)? '@angular/router' : 'node_modules/@angular/router',
'angular2-in-memory-web-api': (isPublic)? 'angular2-in-memory-web-api' : 'node_modules/angular2-in-memory-web-api',
'rxjs': (isPublic)? 'rxjs' : 'node_modules/rxjs'
};
Expand All @@ -23,9 +22,11 @@ var isPublic = typeof window != "undefined";
'common',
'compiler',
'core',
'forms',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade'
];
Expand All @@ -37,20 +38,14 @@ var isPublic = typeof window != "undefined";
function packUmd(pkgName) {
packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
}

packages['@angular/router'] = { main: 'index.js', defaultExtension: 'js' };

// Most environments should use UMD; some (Karma) need the individual index files
var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;

// Add package entries for angular packages
ngPackageNames.forEach(setPackageConfig);

var config = {
map: map,
packages: packages
};

System.config(config);

})(this);

2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Angular2 Express slim starter
### Heroku ready wih SystemJS builder

- Angular 2 rx.2 ( https://angular.io/docs/ts/latest/quickstart.html )
- Angular 2 RC.5 ( https://angular.io/docs/ts/latest/quickstart.html )
- Express ( from generator )

https://express-angular2-slim.herokuapp.com/
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"removeComments": false,
"noImplicitAny": false
},
"angularCompilerOptions": {
"genDir": ".",
"debug": true
},
"exclude": [
"node_modules"
]
Expand Down
2 changes: 1 addition & 1 deletion typings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160602141332",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160621231320"
"node": "registry:dt/node#6.0.0+20160807145350"
}
}

0 comments on commit ab35e8b

Please sign in to comment.