Angular 7.2.13
When navigating with the browser back button, the HTML of the component is loaded, but the component css/js is not loaded, and the page hangs.
However loading works fine when navigated by a link click or router.navigateByUrl() or if the page is reloaded. But never when navigating with the forward/back button.
I'm getting no console errors.
It works perfectly on the development server http://localhost:4200/
. This issue occurs only in production.
UPDATE
This is happening in a child route.
UPDATE 2
Can't replicate the issue in a stackblitz with the same route structure. https://angular-tpsr5z.stackblitz.io/.
UPDATE 3
When it hangs both the previous and the new route html are shown.
After hanging like this the component will immediately load if I click anything that fires a component method, or changes a property of the component.
UPDATE 4
Package Json
{
"name": "tuilder-ng",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^7.2.13",
"@angular/cdk": "^7.3.7",
"@angular/common": "^7.2.13",
"@angular/compiler": "^7.2.13",
"@angular/core": "^7.2.13",
"@angular/forms": "^7.2.13",
"@angular/http": "^7.2.13",
"@angular/material": "^7.3.7",
"@angular/platform-browser": "^7.2.13",
"@angular/platform-browser-dynamic": "^7.2.13",
"@angular/router": "^7.2.13",
"@ecodev/fab-speed-dial": "^3.1.0",
"@google/markerclustererplus": "^2.1.11",
"@swimlane/ngx-charts": "^10.1.0",
"@types/googlemaps": "^3.30.19",
"@types/lodash": "^4.14.123",
"chart.js": "^2.8.0",
"core-js": "^2.6.5",
"lodash": "^4.17.11",
"moment-timezone": "^0.5.23",
"ng2-charts": "^1.6.0",
"ngx-material-timepicker": "^2.13.0",
"ngx-order-pipe": "^2.0.2",
"rxjs": "^6.4.0",
"thenby": "^1.3.0",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.13.8",
"@angular/cli": "^7.3.8",
"@angular/compiler-cli": "^7.2.13",
"@angular/language-service": "^7.2.13",
"@types/jasmine": "^3.3.12",
"@types/jasminewd2": "~2.0.6",
"@types/node": "^10.12.30",
"codelyzer": "~4.5.0",
"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.5",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "^5.4.2",
"ts-node": "^8.0.3",
"tslint": "~5.12.1",
"typescript": "3.2.4"
}
}
Server Redirect .htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Options +FollowSymLinks
DirectoryIndex index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^[a-zA-Z0-9-_.\/]+$ index.html
UPDATE 5
Cut down demo of the issue: https://ngtest.emanweb.design/
The issue was resolved by turning off ModPagespeed in Nginx for that particular domain.
pagespeed Disallow "https://*example.com/*";
ModPagespeed was interacting in some way with Angular to cause this weird behaviour.
Alternatively pagespeed can be turned off per url by appending: ?ModPagespeed=off
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With