参照: https://angular.io/docs/ts/latest/guide/router.html
私のアプリは正常にビルドおよびロードされます。任意のブラウザーで F5 キーを押すと、アプリがハングします。ブラウザーに「読み込み中...」と表示され、コンソールにエラー メッセージは表示されません。
排除することで、 app.html の router-outlet が問題を引き起こしているように見えることがわかりました。router-outlet をコメントアウトすると、アプリは正しくリロードされます。main.ts で LocationStrategy を削除しても効果がないことに注意してください。私は何が欠けていますか?
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>
パッケージ.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"
}
}