When compiling my app and runnning, the HTML page displays as blank and will not show the app. I was able to use the Inspect tool on Google Chrome and Chrome is saying that record.factory is not a function, the page was working fine. However, I did recently update my angular version to the latest - so I am not sure if that has anything to do with it.
Here's my module.ts code, I suspect it's something with the Imports, usually that has been the case when I run into issues with the app not displaying:
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';
import { Platform } from '@angular/cdk/platform';
import { AutofillMonitor } from '@angular/cdk/text-field';
import { ContentObserver } from '@angular/cdk/observers';
@NgModule({
declarations: [
AppComponent,
NewItemFormComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
MatFormFieldModule,
MatInputModule,
BrowserAnimationsModule,
FormsModule
],
providers: [ItemService, Platform, BrowserModule,
AppRoutingModule,
HttpClientModule,
MatFormFieldModule,
MatInputModule,
BrowserAnimationsModule,
FormsModule, AutofillMonitor, ContentObserver],
bootstrap: [AppComponent]
})
export class AppModule { }
Any ideas?
AngularJS Factory Method makes the development process of AngularJS application more robust. A factory is a simple function which allows us to add some logic to a created object and return the created object. The factory is also used to create/return a function in the form of reusable code which can be used anywhere within the application.
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value is not actually a function. Message TypeError: Object doesn't support property or method {x} (Edge) TypeError: "x" is not a function
JS does not see a semicolon after require (), and we start a line with a (, and JS thinks we’re trying to execute a function. It consider require ('fs') as the name of the function, which is something that could actually work if the module export returned a function. But it’s not, so we get that ...is not a function error.
This function is located in this file: node_modules\@angular\core\__ivy_ngcc__\fesm5\core.js. At time of writing, the function starts on line 11345. Hope this helps the next poor soul who sees this error.
I had a similar error, this comment's post helped me. It happens when you use packages compiled in different Angular versions:
"Packages must be compiled and ran using the exact same version of Angular; any other combination is not supported and likely to break in subtle ways."
You have to remove modules from providers array. Remove: BrowserModule, AppRoutingModule, HttpClientModule, MatFormFieldModule, MatInputModule, BrowserAnimationsModule, FormsModule
You need to comment
@Injectable() in your routing or injecting else
Example
// @Injectable() comment this code
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
providers: []
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With