简体   繁体   中英

Angular not loading app.module.ts

Im new to Angular and I started making a web application with springboot and downloaded a dashboard template (ngx-admin) which uses angular and typescript. My problem is when i start my webserver and go to the url it just gives a loading page and doesnt load ngx-app which is devined as such in app.component.ts

/**
 * @license
 * Copyright Akveo. All Rights Reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 */
import { Component, OnInit } from '@angular/core';
import { AnalyticsService } from './@core/utils/analytics.service';

@Component({
  selector: 'ngx-app',
  template: '<router-outlet></router-outlet>',
})
export class AppComponent implements OnInit {

  constructor(private analytics: AnalyticsService) {
  }

  ngOnInit(): void {
    this.analytics.trackPageViews();
  }
}

and in my html I call Loading...

the problem here is with <router-outlet></router-outlet> because the content inside router-outlet is only loaded from other component when you change or open any other route in your application.So if you only have a root url and no other routes in your application it will display the default loading... text.

you can try to change the template as below to see if it works ..

template: '<h2>ngx app is running</h2>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM