我正在尝试将ionic-tooltips模块与Ionic v4结合使用。该模块已通过npm安装。
创建一个新的空白项目,并按照模块站点中的安装步骤进行操作,我遇到了一些问题。首先,有了一些缺少的组件,我能够手动更改某些文件的导入,就像在此question中一样。
之后,我又遇到了另一个错误:
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
经过一些搜索,我得到了一些会聚到相同solution的遮篷:将Ionic CommonModule导入到您的主模块。我做到了,没有成功。
我的 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 (我最后一次尝试导入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 {}
如果缺少任何信息,请询问。