【问题标题】:Can't bind to 'ngIf' since it isn't a known property of 'ion-col'不能绑定到 \'ngIf\',因为它不是 \'ion-col\' 的已知属性
【发布时间】:2022-11-10 23:14:32
【问题描述】:

我想渲染列,只有在满足规则的情况下,但它无法识别我。

角度

HTML
<div class="middlePoint">
    <ion-row>
      <ion-col class="col-12 text-center titles mt-5"> Ingresa tu PIN </ion-col>
      <ion-col class="col-12 mt-2">
        <ul class="pinCircle">
          <li [class]="mePin.length > 0 ? 'active' : ''"></li>
          <li [class]="mePin.length > 1 ? 'active' : ''"></li>
          <li [class]="mePin.length > 2 ? 'active' : ''"></li>
          <li [class]="mePin.length > 3 ? 'active' : ''"></li>
        </ul>
      </ion-col>
      <ion-col class="mt- 2" size="12" *ngIf="messageError.length > 0">
        <h3 class="text-center color-white">{{ messageError }}</h3>
      </ion-col>
      <ion-col size="12" class="my-loading" *ngIf="loading === true">
        <ion-spinner name="dots"></ion-spinner>
      </ion-col>
    </ion-row>
</div>

COMPONENT.TS
    
@Component({
  selector: "app-pin",
  templateUrl: "./pin.component.html",
  styleUrls: ["./pin.component.scss"],
})
export class PinComponent implements OnInit {
  public messageError: string = "";
  public loading: boolean = true;
  public circlePin: any = 0;
  public mePin: any = "";

我想渲染列,只有在满足规则的情况下,但它无法识别我。

【问题讨论】:

标签: javascript angular ionic-framework ionic5


【解决方案1】:

而不是将*ngIf 添加到&lt;ion-col&gt;

尝试使用:

<ng-container *ngIf="condition">
  …
</ng-container>

https://angular.io/api/core/ng-container#usage-notes

另外,检查您的模块是否有 CommonModule 导入。

【讨论】:

    【解决方案2】:

    检查你是否在你的地点.module.ts 像这样:

    import { CommonModule } from '@angular/common';
    
    @NgModule({
    imports: [CommonModule],
    declarations [Page]
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-08
      • 2021-01-06
      • 1970-01-01
      • 2021-10-11
      • 1970-01-01
      • 1970-01-01
      • 2017-10-29
      相关资源
      最近更新 更多