[英]Angular javascript page compiles but shows blank
When I compile my Angular app it works, but the HTML page is blank and it my application will not display.当我编译我的 Angular 应用程序时,它可以工作,但 HTML 页面是空白的,我的应用程序不会显示。 I've had issues like this before and usually it has been one of the Imports, but I'm not sure now.
我以前遇到过这样的问题,通常是进口之一,但我现在不确定。 When I use Google Chrome to inspect, the error that I see is record.factory is not a function .
当我使用谷歌浏览器进行检查时,我看到的错误是record.factory is not a function 。 Is anyone familiar with this?
有没有人熟悉这个?
Here is my module.ts code:这是我的 module.ts 代码:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { ItemService } from './items.service';
import { NewItemFormComponent } from './new-item-form/new-item-form.component';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
@NgModule({
declarations: [
AppComponent,
NewItemFormComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
MatFormFieldModule,
MatInputModule,
BrowserAnimationsModule,
FormsModule
],
providers: [ItemService, BrowserModule,
AppRoutingModule,
HttpClientModule,
MatFormFieldModule,
MatInputModule,
BrowserAnimationsModule,
FormsModule],
bootstrap: [AppComponent]
})
export class AppModule { }
You placed in wrong place couple of your modules.您将几个模块放在错误的位置。 You should put them into
imports
section, not providers
.您应该将它们放入
imports
部分,而不是providers
。 I am talking我正在说话
BrowserModule,
AppRoutingModule,
HttpClientModule,
MatFormFieldModule,
MatInputModule,
BrowserAnimationsModule,
FormsModule
Also there might be problem if you have @Injectable
and @NgModule
decorators added to same class.如果您将
@Injectable
和@NgModule
装饰器添加到同一个类中,也可能会出现问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.