Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ionic v4)] Can’t bind to ‘ngIf’ since it isn’t a known property of ‘div’ #67

Closed
leonardofmed opened this issue Apr 29, 2019 · 1 comment

Comments

@leonardofmed
Copy link

I’m trying to use the module with Ionic v4. The module was installed with npm.

Creating a new blank project and following the installation steps 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. I see that the module was updated to Ionic v4, but this imports are still linking with the ionic v3 structure, is this a currently problem or the npm package is outdated?

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 the 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.

@leonardofmed
Copy link
Author

leonardofmed commented May 3, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant