Modal组件主要用来弹出一些临时的框,如登录,注册的时候用

弹出页面html页面

<button ion-button small outline  color="he" (click)="register()">还没有账号,点击注册</button>

弹出页面的ts文件

import { Component } from '@angular/core';
import { ModalController } from 'ionic-angular';
import { RegisterPage } from '../register/register';//需要弹出的页面 @Component({
selector: 'page-contact',
templateUrl: 'contact.html'
})
export class ContactPage { constructor(public modalCtrl: ModalController) { } register(){
let modal = this.modalCtrl.create(RegisterPage);
modal.present();
}
}

被弹出页面的html(页面上设置关闭按钮用来关闭弹出页dismiss

<ion-header>
<ion-navbar>
<ion-title>用户注册</ion-title>
<ion-buttons end>
<button ion-button clear (click)="dismiss()">
<span showWhen="ios">取消</span>
<ion-icon name="md-close" showWhen="android"></ion-icon>
</button>
</ion-buttons>
</ion-navbar> </ion-header> <ion-content padding> </ion-content>

被弹出页面的ts文件(用ViewController来关闭当前弹出页面

import { Component } from '@angular/core';
import { ViewController } from 'ionic-angular'; @IonicPage()
@Component({
selector: 'page-register',
templateUrl: 'register.html'
})
export class RegisterPage { constructor(public viewCtrl: ViewController) {
} dismiss(){
this.viewCtrl.dismiss();
} }

弹出页面是新生成的组件的话,记得修改app.moudle.ts文件,添加如下文件

import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component'; import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
//引入新建的页面
import { RegisterPage } from '../pages/register/register';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs'; import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen'; @NgModule({
declarations: [
MyApp,
AboutPage,
ContactPage,
RegisterPage,//添加
HomePage,
TabsPage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp) ],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
AboutPage,
ContactPage,
RegisterPage,//添加
HomePage,
TabsPage
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}

ionic3 Modal组件的更多相关文章

  1. 利用bootstrap的modal组件自定义alert,confirm和modal对话框

    由于浏览器提供的alert和confirm框体验不好,而且浏览器没有提供一个标准的以对话框的形式显示自定义HTML的弹框函数,所以很多项目都会自定义对话框组件.本篇文章介绍自己在项目中基于bootst ...

  2. 动手实现react Modal组件

    Modal组件 长话不多说,接下来让我们来动手实现一个react Modal组件. 我们先来看一下实际效果 Modal的布局 首先,让我们先思考下一个Modal组件的布局是怎么样的. 我们先拿一个基本 ...

  3. vue组件中,iview的modal组件爬坑--modal的显示与否应该是使用v-show

    这是我第一次写博客,主要是记录下自己解决问题的过程和知识的总结,如有不对的地方欢迎指出来! 需求:点击btn,弹出modal显示图表(以折现图为例) 这应该是很基本的需求也是很容易实现的,代码和效果如 ...

  4. vue-strap 修改Modal组件

    在用到vue-strap的Modal组件时,会有两个默认按钮,查看官方文档配置如下: 可以看到,ok-text和cancel-text都有一个默认值,在使用时即使不给这两个选项赋值,也会显示两个默认文 ...

  5. 移动端 Modal 组件开发杂谈

    Vant 是有赞开发的一套基于 Vue 2.0 的 Mobile 组件库,在开发的过程中也踩了很多坑,今天我们就来聊一聊开发一个移动端 Modal 组件(在有赞该组件被称为 Popup )需要注意的一 ...

  6. 微信小程序把玩(二十三)modal组件

    原文:微信小程序把玩(二十三)modal组件 modal弹出框常用在提示一些信息比如:退出应用,清楚缓存,修改资料提交时一些提示等等. 常用属性: wxml <!--监听button点击事件-- ...

  7. Ionic3 UI组件之 Gallery Modal

    Gallery Modal可以理解为相册的预览界面.可以显示网络图片,也可以显示base64Image. 在这个例子中,我用来实现图片的预览功能. 相机拍照,或者相册选择图片后,用缩略图组件显示缩略图 ...

  8. ionic3 自定义组件 滑动选择器 ion-multi-picker

    1.ionic3中有一个 ion-datatime 给大家选择时间提供了一个很方便的组件 效果如图  链接  https://ionicframework.com/docs/api/component ...

  9. Ionic3,组件的使用(四)

    说明 因为同样是作为 Ionic3 小白,所以很多东西都是自己摸索出来的,可能有很多不合理的地方,请多多指正. 效果图 细节说明 一:组件.页面均采用 懒加载: 二:页面的头部标题栏,采用了组件化的方 ...

随机推荐

  1. [Swift]LeetCode159.具有最多两个不同字符的最长子串 $ Longest Substring with At Most Two Distinct Characters

    Given a string S, find the length of the longest substring T that contains at most two distinct char ...

  2. [Swift]LeetCode348. 设计井字棋游戏 $ Design Tic-Tac-Toe

    Design a Tic-tac-toe game that is played between two players on a n x n grid. You may assume the fol ...

  3. [Swift]LeetCode816. 模糊坐标 | Ambiguous Coordinates

    We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)".  Then, we re ...

  4. [Swift]LeetCode1026. 节点与其祖先之间的最大差值 | Maximum Difference Between Node and Ancestor

    Given the root of a binary tree, find the maximum value V for which there exists different nodes A a ...

  5. vue实例属性的方法

    1.$mount()   手动设置挂载点  eg:vm.$mount("#app") 2.$destroy()  销毁   eg:vm.$destroy(); 3.$forceUp ...

  6. JS 中 原生方法 (四) --- Object

    Javascript 中 str. arr.date.obj 等常见的原生方法总结 本文也说主要阐释了 Javascript 中的基础类型和 引用类型的自带方法,那么熟悉的同学又可以绕道了 总是绕道, ...

  7. JavaScript 中 正则替换 replace

    本文初步介绍 replace 在 js 中,我们常常会遇到 用来 解决开发中常会遇到的 问题的 知识总结, 如果你已经 非常熟悉,又可以绕道了. 定义和用法 replace() 方法用于在字符串中常用 ...

  8. Asp.Net MVC路由生成URL过程

    这次谈一谈Asp.Net MVC中所学到的路由生成URL的相关技术,顺便提一提遇到的一些坑,真的是掉坑掉多了,也就习以为常了,大不了从坑里再爬出来.初学者,包括我,都以为,mvc的核心是模型视图控制器 ...

  9. C++中 引用&与取地址&的区别

    微信公众号[程序员江湖] 作者黄小斜,斜杠青年,某985硕士,阿里 Java 研发工程师,于 2018 年秋招拿到 BAT 头条.网易.滴滴等 8 个大厂 offer,目前致力于分享这几年的学习经验. ...

  10. 实现一个简单的WebSocket聊天室

    WebSocket 简介 WebSocket 是 HTML5 开始提供的一种在单个 TCP 连接上进行全双工通讯的协议. WebSocket 使得客户端和服务器之间的数据交换变得更加简单,允许服务端主 ...