[Ionic v4 (ionic-tooltips)] Can't bind to 'ngIf' since it isn't a known property of 'div'

I’m trying to use the ionic-tooltips with Ionic v4.

Creating a new blank project and following the installation steps from the module site I got some problems. First with some missing components that I was able to fix manually changing the imports of some files, just like in this question.

After that I got this other error:

ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'ngIf' since it isn't a known property of 'div'. ("
    <div [ERROR ->]*ngIf="tooltipHtml; else txt" [innerHTML]="tooltipHtml"></div>
    <ng-template #txt>{{ text }}</ng-t"): ng:///TooltipsModule/TooltipBox.html@1:9
Can't bind to 'ngIfElse' since it isn't a known property of 'div'. ("
    <div [ERROR ->]*ngIf="tooltipHtml; else txt" [innerHTML]="tooltipHtml"></div>
    <ng-template #txt>{{ text }}</ng-t"): ng:///TooltipsModule/TooltipBox.html@1:9
Property binding ngIf not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("
    [ERROR ->]<div *ngIf="tooltipHtml; else txt" [innerHTML]="tooltipHtml"></div>
    <ng-template #txt>{{ text }}<"): ng:///TooltipsModule/TooltipBox.html@1:4
Property binding ngIfElse not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("
    [ERROR ->]<div *ngIf="tooltipHtml; else txt" [innerHTML]="tooltipHtml"></div>
    <ng-template #txt>{{ text }}<"): ng:///TooltipsModule/TooltipBox.html@1:4
Error: Template parse errors:
Can't bind to 'ngIf' since it isn't a known property of 'div'. ("
    <div [ERROR ->]*ngIf="tooltipHtml; else txt" [innerHTML]="tooltipHtml"></div>
    <ng-template #txt>{{ text }}</ng-t"): ng:///TooltipsModule/TooltipBox.html@1:9
Can't bind to 'ngIfElse' since it isn't a known property of 'div'. ("
    <div [ERROR ->]*ngIf="tooltipHtml; else txt" [innerHTML]="tooltipHtml"></div>
    <ng-template #txt>{{ text }}</ng-t"): ng:///TooltipsModule/TooltipBox.html@1:9
Property binding ngIf not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("
    [ERROR ->]<div *ngIf="tooltipHtml; else txt" [innerHTML]="tooltipHtml"></div>
    <ng-template #txt>{{ text }}<"): ng:///TooltipsModule/TooltipBox.html@1:4

After some searching I got some awnsers that converged to the same solution: Import Ionic CommonModule to your main Module. I did this, no success.

My home.page.html:

<ion-content>
  	<ion-button tooltip="I'm a tooltip below a button" positionV="bottom" arrow>
	   Press me to see a tooltip
	  </ion-button>
</ion-content>

home.module.ts:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';

import { HomePage } from './home.page';

import { TooltipsModule } from 'ionic-tooltips';

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    RouterModule.forChild([
      {
        path: '',
        component: HomePage
      }
    ]),
    TooltipsModule.forRoot()
  ],
  declarations: [HomePage]
})
export class HomePageModule {}

app.module.ts (where I lastly tried to import CommonModule):

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

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

If there is any missing info, please ask.

import { CommonModule } from ‘@angular/common’;

@NgModule({
    imports: [CommonModule],
    declarations: [MyComponent]
  ...
})

Please add it app.module.ts

As I mentioned in my question, I already did that and it did not work.

I was able to use tooltips with Ionic v4 using other library, popperjs with the angular wrapper ngx-popper.

I’m facing the same problems and will use another way to have tooltips. Lost 2 hours of work trying to make it work.

Hi there, I have also the same problem. please help me.

Maybe, your page module is not getting loaded. Try PreLoadAllModules in the app-routing.module.ts
I was using a page in an external modal and had to PreLoadAllModules to run its module.ts file

4 Likes

thank you so much for your help it’s working for me

1 Like