沈斌
2017-12-16 f047b77624fd1b58bed9e80751b37eb002264305
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Component } from '@angular/core';
import { NzModalService, NzMessageService } from 'ng-zorro-antd';
import { ModelCustomComponent } from './custom.component';
 
@Component({
    selector: 'app-modal',
    templateUrl: './modal.component.html'
})
export class ModalComponent {
    options = {};
 
    constructor(
        private modal: NzModalService,
        private msg: NzMessageService) { }
 
    basicModel(contentTpl) {
        this.modal.open({
            title: 'Basic Modal',
            content: contentTpl
        });
    }
 
    confirmModel(contentTpl) {
        this.modal.open({
            title: 'Confirm Modal',
            content: contentTpl,
            okText: 'OK',
            cancelText: 'Return',
            onOk: () => {
                this.msg.success('Click OK!');
            },
            onCancel: () => {
                this.msg.error('Click Return!');
            }
        });
    }
 
    customCompModel(size: '' | 'lg' | 'sm' = '') {
        this.options = {
            wrapClassName: size ? 'modal-' + size : '',
            content: ModelCustomComponent,
            footer: false,
            componentParams: {
                name: 'From Parent Data'
            }
        };
        this.modal.open(this.options).subscribe(result => {
            this.msg.info(`subscribe status: ${JSON.stringify(result)}`);
        });
    }
 
    showModel(type: string) {
        this.modal[type]({
            title: `This is a ${type} message`,
            content: `some messages...some messages...`
        });
    }
}