Skip to content
This repository has been archived by the owner on Jun 13, 2020. It is now read-only.

[Angular] Unexpected behaviour when directly accessing application #54

Open
mzellho opened this issue May 13, 2019 · 1 comment
Open
Assignees

Comments

@mzellho
Copy link

mzellho commented May 13, 2019

I noticed some strange behaviour when accessing the Angular App via ng serve.

Please note: all of this can easily be reproduced by checking out angular/chapter-8 and running ng serve --proxy-config ./proxy.mock.conf.json or ng test

When accessing the application at http://localhost:4200, the application cannot initialize correctly and throws two (!) "ERROR Error: "Uncaught (in promise): Object: {"response":{}}"".

Since the URL in the browser got updated to http://localhost:4200/content/wknd-events/angular/home.html, F5'ing will correctly load the application. Resetting the URL to http://localhost:4200 unsurprisingly leads to the same error.

I tried to dig into this error, but couldn't find the reason. I highly suspect it has something to do with the initialization of ModelManager. I tried many ways of delaying the initialization until the URL of the browser got updated, but couldn't get it working.

Since in production we anyways would call a "complete" URL, this would work there, but I am having a really hard time writing tests as the tests would access http://localhost:9876 and no "complete" URL.

I am mainly using the mock-json-approach which is working fine for development purposes. Any ideas whether this approach could also work in combination with ng test and a proxy config in karma.conf?

P.S.: Tests in this tutorial are failing as well - any chance we could get a chapter on testing?

@mzellho mzellho changed the title [Angular] Unexpected when directly accessing application [Angular] Unexpected behaviour when directly accessing application May 13, 2019
@godanny86
Copy link
Collaborator

hi @mzellho thank you for raising! We will take a closer look at this. I think the model manager changed slightly and we need to update the app routing logic for this. I'd encourage you to look at: https://github.com/adobe/aem-spa-project-archetype for the latest testing strategies and the We.Retail Journal app for another example of app routing: https://github.com/adobe/aem-sample-we-retail-journal/blob/master/angular-app/src/app/app-routing.module.ts

@godanny86 godanny86 self-assigned this May 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants