Angular-cli: Initial JavaScript-Function should wait for the DOM to be ready before searching for the root-component

Created on 6 May 2017  路  3Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues befre submitting
- [x ] feature request

Versions.

@angular/cli: 1.0.1
node: 6.9.1
os: win32 x64

Desired functionality.

Visual Studio Services Extensions currently allow only to add Javascript in their headers.
See this discussion: http://stackoverflow.com/questions/43766463/vsts-extension-with-angular2
And my Repo with a test: https://github.com/DrMueller/Ng-Vsts

Unfortunately, this doesn't work with the Angular-CLI JavaScript packages, since they expect the DOM to be loaded, throwing an error because the logic doesn't find the root-component.

I would like like the JavaScript to listen to the DOM-Ready event, before starting to search for the root.

Most helpful comment

You can change the bootstrapping code in the src/main.ts file from:

platformBrowserDynamic().bootstrapModule(AppModule);

to:

document.addEventListener('DOMContentLoaded', () => {
  platformBrowserDynamic().bootstrapModule(AppModule);
});

All 3 comments

You can change the bootstrapping code in the src/main.ts file from:

platformBrowserDynamic().bootstrapModule(AppModule);

to:

document.addEventListener('DOMContentLoaded', () => {
  platformBrowserDynamic().bootstrapModule(AppModule);
});

Closed as answered by @Meligy, thank you!

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

5amfung picture 5amfung  路  3Comments

delasteve picture delasteve  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments

JanStureNielsen picture JanStureNielsen  路  3Comments