The selector “my-app” did not match any elements

前端 未结 12 1150
逝去的感伤
逝去的感伤 2020-12-07 18:15

The problem is when I run my app, it works fine. But when I refresh it, most of the time I get below msg.

The selector \"my-app\" did not match any e

12条回答
  •  青春惊慌失措
    2020-12-07 19:00

    Things to do:

    1. Go to app.module.ts (to main modules, in most cases this is a name)
    2. Check if you have part "boostrap:" - if no add:

      bootstrap: [AppComponent] // where AppComponent is your main component

    3. Check if it works now, if not - go to AppComponent and check your selector. It should be same as tags in body in index.html

    so index.html should contain something like this:

    
      Loading...
    
    

    where instead of you should use selector from main AppComponent

    1. If you are using your angular app in external website then you should consider using defer in headers for angular files

提交回复
热议问题