沈斌
2017-12-15 f9b157566af34b8dc28ba10b34d025ac04f3168b
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
import { Component, Input } from '@angular/core';
import { NzModalSubject, NzModalService, NzMessageService } from 'ng-zorro-antd';
import { ModalHelper } from '@delon/theme';
 
@Component({
    selector: 'app-model-custom',
    template: `
    <div class="modal-header">
        <div class="modal-title">Custom component</div>
    </div>
    <h3>From Custom Componetn!</h3>
    <p>Input Data: {{name}}</p>
    <p>submodal: <a (click)="show()">show</a></p>
    <p>
        Popconfirm 气泡确认框:
        <nz-popconfirm [nzTitle]="'确定要删除这个任务吗?'">
            <a nz-popconfirm>删除</a>
        </nz-popconfirm>
    </p>
    <div class="modal-footer">
        <button nz-button [nzType]="'default'" [nzSize]="'large'" (click)="cancel()">
            Cancel
        </button>
        <button nz-button [nzType]="'primary'" [nzSize]="'large'" (click)="ok()">
            OK
        </button>
    </div>
    `
})
export class ModelCustomComponent {
 
    @Input() name: string;
 
    constructor(
        private modalHelper: ModalHelper,
        private model: NzModalService,
        private msg: NzMessageService,
        private subject: NzModalSubject) {}
 
    show() {
        this.modalHelper
            .open(ModelCustomComponent, { name: 'From Submodal Data' }, 'sm', {
                zIndex: 1001 // https://github.com/NG-ZORRO/ng-zorro-antd/issues/317
            })
            .subscribe(result => this.msg.info(`subscribe sub status: ${JSON.stringify(result)}`));
    }
 
    ok() {
        this.subject.next(`new time: ${+new Date}`);
        this.cancel();
    }
 
    cancel() {
        this.subject.destroy();
    }
}