1

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"
  }
}
  • 1
    Please show us your `app.routes.ts` file! :) – Maximilian Riegler Jul 18 '16 at 15:14
  • I've removed my routes - and the components they refer to - in the process of elimination to solve this problem. The deconstructed example I am showing does not actually route anything. I am only trying the solve the F5 problem. For the record my app does route correctly - the problem I am trying to solve is the browser refresh. Thx. –  Jul 18 '16 at 15:18
  • I'm not sure what you mean by "hang" but it might be client angular routing fighting with your server routing (ex. ASP.net MVC)? – vidalsasoon Jul 18 '16 at 16:17
  • By hangs I mean totally stops working..freezes...stops....dies...etc. I don't think I have a conflict with server routing. I upgraded from router 2 to router 3 and from rc1 to rc4. That's the only change. –  Jul 18 '16 at 18:56

0 Answers0