Reference: https://angular.io/docs/ts/latest/guide/router.html
My app builds and loads fine. When I hit F5 in any browser the app hangs: It displays "loading..." in the browser and no error message appears in the console.
By elimination I discovered that router-outlet in app.html appears to cause the problem. When I comment out router-outlet the app reloads correctly. Note that removing LocationStrategy in main.ts has no effect. What am I missing?
main.ts
import { provide } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';
import { LocationStrategy, HashLocationStrategy } from '@angular/common';
import { AppComponent } from './app.component';
import { APP_ROUTER_PROVIDERS } from './app.routes';
bootstrap(AppComponent, [APP_ROUTER_PROVIDERS, provide(LocationStrategy, { useClass: HashLocationStrategy })]);
app.component.ts
import { Component } from '@angular/core';
import { ROUTER_DIRECTIVES } from '@angular/router';
@Component({
selector: 'my-app',
templateUrl: './app/app.html',
directives: [ROUTER_DIRECTIVES]
})
export class AppComponent {
}
app.html
<!--<router-outlet></router-outlet>-->
<h1>this is app.html</h1>
package.json
{
"version": "1.0.0",
"name": "samsblog",
"private": true,
"scripts": {
"start": "webpack-dev-server --inline --progress --port 8080",
"test": "karma start",
"build": "webpack --progress --profile --bail --display-error-details --minimize",
"postinstall": "typings install"
},
"dependencies": {
"@angular/common": "2.0.0-rc.4",
"@angular/compiler": "2.0.0-rc.4",
"@angular/core": "2.0.0-rc.4",
"@angular/http": "2.0.0-rc.4",
"@angular/platform-browser": "2.0.0-rc.4",
"@angular/platform-browser-dynamic": "2.0.0-rc.4",
"@angular/router": "^3.0.0-beta.1",
"@angular/upgrade": "2.0.0-rc.4",
"bootstrap": "^3.3.6",
"core-js": "^2.4.0",
"es6-shim": "^0.35.0",
"html-webpack-plugin": "^2.22.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"ts-loader": "^0.8.2",
"zone.js": "^0.6.12"
},
"devDependencies": {
"css-loader": "^0.23.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"image-webpack-loader": "^2.0.0",
"source-map-loader": "^0.1.5",
"style-loader": "^0.13.1",
"typescript": "^1.8.10",
"typings": "^1.0.4",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1",
"webpack-merge": "^0.14.0"
}
}