import { Component, EventEmitter, Output } from '@angular/core'; import { NavParams } from 'ionic-angular' import { ModalOption } from '../type' const defaultOption: ModalOption = { title: '温馨提示', content: '', icon: false, okText:'确认', cancelText:'取消' } @Component({ selector: 'modal-confirm', template:'' + '' + '' + '' + '
' }) export class ModalConfirmComponent { option: ModalOption = defaultOption; constructor(params: NavParams) { this.option = Object.assign({},this.option,params.data); } // 点击确定 @Output() okEvent = new EventEmitter(); ok = () => { this.okEvent.emit(true); } // 点击取消 @Output() cancelEvent = new EventEmitter(); cancel = () => { this.cancelEvent.emit(false); } }