返回

<app-root> 为空且未填充

发布时间:2022-08-17 01:30:25 305
# css# html# bootstrap# angular# 工具

我是角度的初学者,我正在尝试制作一个博客应用程序。但是,每当我运行 ng serve 并查看开发人员工具时,我发现 app-root 是空的。(告诉我是否需要包含更多文件)

我也收到此错误:

Error: NullInjectorError: No provider for Compiler!

另外:这不是这个的副本,我已经尝试了解决方案,但它们不适用于我的 senario

app.modules.ts

import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AngularFireAuthModule, USE_EMULATOR as USE_AUTH_EMULATOR } from '@angular/fire/auth';
import { AngularFirestoreModule, USE_EMULATOR as USE_FIRESTORE_EMULATOR } from         '@angular/fire/firestore';
import { AngularFireFunctionsModule, USE_EMULATOR as USE_FUNCTIONS_EMULATOR } from '@angular/fire/functions';
import { environment } from '../environments/environment';
import { AngularFireModule } from '@angular/fire';
import { AngularFireStorageModule } from '@angular/fire/storage';
import { TimelineComponent } from './timeline/timeline.component';
import { articleComponent } from './article/article.component';
import { AppRoutingModule } from './app-routing.module';
import { HttpClientModule } from '@angular/common/http';

@NgModule({
  declarations: [
    TimelineComponent,
    // CoursesCardListComponent,
    articleComponent,
  ],
  imports: [
    AppRoutingModule,
    HttpClientModule,
    AngularFireModule.initializeApp(environment.firebase),
    AngularFirestoreModule,
    AngularFireStorageModule,
    AngularFireAuthModule,
    AngularFireFunctionsModule
  ],
  bootstrap: [AppComponent]
})
export class AppModule { } 

app.component.ts

import { Component } from '@angular/core';
import { Observable } from 'rxjs';
import { Router } from '@angular/router';
import { appservice } from './services/services';
import { Entrys } from './model/entrys';


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {

  constructor(
    private router: Router,
    private appService: appservice) { }

  ngOnInit() {

    this.reloadArticles();

  }

  articles$: Observable<Entrys[]>

  public show: boolean = true;

  clicked() {
    this.show = false;
  }


  reloadArticles() {
    this.articles$ = this.appService.loadAllArticles()    
  }

}

index.html 只是您正常的角度项目

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(2)
按点赞数排序
用户头像