0

I just created an app using Ionic and Angular, but I always get the following error, it doesn't matter if I put the html into the ionic generated "pages" folder or in my newly made page.

Ionic version 5.4.16 Angular version 11.2.13

enter image description here

This is my LoginPage html

<ion-header>
  <ion-toolbar>
    <ion-title>OSCheckin</ion-title>
  </ion-toolbar>
</ion-header>
<div>
  <div class="d-flex h-100">
    <div class="m-auto w-75">
      <IonItem>
          <IonLabel>Email</IonLabel>
          <IonInput value="" placeholder="Ex.: [email protected]" type="email"></IonInput>
      </IonItem>
      <IonItem>
          <IonLabel>Senha</IonLabel>
          <IonInput value="" placeholder="*********"></IonInput>
      </IonItem>
      <IonButton onClick="" expand="block">Entrar</IonButton>
    </div>
  </div>
</div>

this is my login module:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';

import { IonicModule } from '@ionic/angular';

import { LoginPageRoutingModule } from './login-routing.module';

import { LoginPage } from './login.page';

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    LoginPageRoutingModule
  ],
  declarations: [LoginPage]
})
export class LoginPageModule {}

And this is my AppModule:

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [
    BrowserModule, 
    IonicModule.forRoot(), 
    AppRoutingModule,
    FormsModule
  ],
  providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
  bootstrap: [AppComponent]
})
export class AppModule {}

Thanks in advance :)

2 Answers 2

1

I believe you'll fix it by adding the angular common module with your ionic module

ie: AppModule.ts

import { CommonModule } from '@angular/common';

@NgModule({
  ...
  imports: [
    CommonModule
Sign up to request clarification or add additional context in comments.

5 Comments

Really hoped that this was the answer but it didn't make a diference :(
Just to make sure, you're adding CommonMOdule to each module.ts file (that also uses IonicMOdule)?
Yeah, I included it in every module.ts files that I could after you've suggested it, even the routing ones, but it didn't work, tried one by one btw. I'll try creating another project with an older Angular version to check if I can make it work
Hey, it worked on Angular 9. I'll "report" this on the official forum. Thx anyway mate ;)
You wont believe it........ I'm so mad with myself rn, the issue was that I was trying to use IonButton, IonItem, etc, the correct was ion-button, ion-item, etc
0

Ok, so this was pretty basic, my mistake was that I was trying to use the components like the following:

<IonButton></IonButton>
<IonItem></IonItem>
etc

the correct was

<ion-button></ion-button>
<ion-item></ion-item>
etc

really can't believe I lost 2 hours on this

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.