html - Ionic 4 showWhen hideWhen

标签 html ionic-framework angular-directive ionic4

我正在尝试对网络和设备使用相同的 html,并且在某些情况下我需要显示/隐藏网络 html 或设备 html。

showWhen 在哪里和 hideWhen Ionic 4 中的指令?如果它们消失了,是否已被其他东西取代?

到目前为止,我能找到的是 some test page但这并没有说明什么。

最佳答案

为了将我的应用程序升级到 ionic 4,我使用了这个替代方案 https://ionicframework.com/docs/utilities/platform根据设备的操作系统显示正确的按钮,效果很好而且很容易实现:

import { Component, OnInit} from '@angular/core';
import { Platform } from '@ionic/angular';

@Component({
  selector: 'update-password',
  templateUrl: './update-password.component.html'
})
export class UpdatePasswordComponent implements OnInit {

  constructor(
    public platform: Platform
  ) { }
<ion-header>
  <ion-toolbar>
    <ion-title>Update Password</ion-title>
    <ion-buttons slot="start">
      <ion-button (click)="dismiss()">
        <ion-text color="primary" *ngIf="platform.is('ios')">Cancel</ion-text>
        <ion-icon name="md-close" *ngIf="!platform.is('ios')"></ion-icon>
      </ion-button>
    </ion-buttons>
  </ion-toolbar>
</ion-header>

关于html - Ionic 4 showWhen hideWhen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53248964/

相关文章:

html - :visited and :active selectors 之间的区别

javascript - 在循环中添加带有参数的事件监听器

javascript - 一次显示一个指令 AngularJS

html - 我可以让这个字体有一个线宽,以便它在下一行继续吗?

html - 可以将多个图像分组到一个 div 中吗

javascript - ionic 部署上未加载插件

angular - 从指令中创建/获取 TemplateRef

angular - 检查组件上是否存在输出

ios - 在 iPhone 上解析时格式化 JSON 以换行

iOS webrtc 应用程序使用 cordova-plugin-iosrtc : video element issues