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]LeetCode317. 建筑物的最短距离 $ Shortest Distance from All Buildings

    You want to build a house on an empty land which reaches all buildings in the shortest amount of dis ...

  2. [SQL]LeetCode601. 体育馆的人流量 | Human Traffic of Stadium

    SQL架构 Create table If Not Exists stadium (id int, visit_date DATE NULL, people int) Truncate table s ...

  3. 如何将项目上传到GitHub?

    如何将项目上传到GitHub? 1.注册GitHub账户 浏览器输入GitHub官网地址:https://github.com/ 进入后点击Sign In 然后点击Create an account ...

  4. Thrift 代码分析

    Thrift的基本结束 Thrift是一个跨语言的服务部署框架,最初由Facebook于2007年开发,2008年进入Apache开源项目.Thrift通过IDL(Interface Definiti ...

  5. python编程实战

    1.计算对称平方数 题目描述 打印所有不超过n(n<256)的,其平方具有对称性质的数,如11*11=121. 输入描述 无 输出描述 每行一个数,表示对称平方数 def f(n): flag ...

  6. Redux源码学习笔记

    https://github.com/reduxjs/redux 版本 4.0.0 先了解一下redux是怎么用的,此处摘抄自阮一峰老师的<Redux 入门教程> // Web 应用是一个 ...

  7. Python内置函数(5)——bin

    英文文档: bin(x) Convert an integer number to a binary string. The result is a valid Python expression. ...

  8. RAC集群数据库连库代码示例(jdbc thin方式,非oci)

    1.RAC集群数据库连库代码示例(jdbc thin方式,非oci):jdbc.driverClassName=oracle.jdbc.driver.OracleDriverjdbc.url=jdbc ...

  9. AspNetCoreMvc使用MongoDB,快来get一下吧。

    看这篇文章之前请耐心看完MongoDb入门,如果还是坚持不看,那我也没有办法. MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案. ...

  10. Zara带你快速入门WPF(2)---布局篇

    一.章节目标 这几章节我们会创建一个完整的Window程序,包括使用DataGrid空间,数据绑定是把.NET类中的数据提供给用户界面的一个重要概念,还允许修改数据,包括.NET4.5新增的INoti ...