Angular日期选择器模式不如预期的出现。
创始人
2024-10-29 05:30:42
0

在模板上添加一个按钮,点击按钮时打开模态对话框。使用ngModel绑定来获取所选日期。以下是可用的代码示例:

在模板上添加的按钮:

在组件.ts文件中:

import { Component } from '@angular/core'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap';

@Component({ selector: 'app-datepicker', template: '', styleUrls: ['./datepicker.component.css'] }) export class DatepickerComponent {

selectedDate: any;

constructor(private modalService: NgbModal) { }

openDatePicker() {
    const modalRef = this.modalService.open(NgbdModalContent);
    modalRef.componentInstance.data = { selectedDate: this.selectedDate };
    modalRef.result.then((result) => {
        if (result !== undefined) {
            this.selectedDate = result;
        }
    }, (reason) => {
        console.log(reason);
    });
}

}

在模态对话框组件中:

import { Component, Input } from '@angular/core'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';

@Component({ selector: 'ngbd-modal-content', templateUrl: './modal-content.component.html' }) export class NgbdModalContent { @Input() data;

constructor(private activeModal: NgbActiveModal) { }

get selectedDate() {
    return this.data.selectedDate;
}

set selectedDate(date: any) {
    this.data.selectedDate = date;
}

closeModal() {
    this.activeModal.close(this.selectedDate);
}

}

在模态对话框组件的HTML模板中:

相关内容

热门资讯

规律辅助挂!hhpoker辅助... 规律辅助挂!hhpoker辅助器视频,德扑之心免费透视,总是确实有挂(有人有挂)1、任何德扑之心免费...
有了最新消息!wpk辅助器是真... 有了最新消息!wpk辅助器是真的吗,德普之星辅助器怎么用,一贯存在有挂(确实有挂)1、进入到德普之星...
据了解!wpk辅助器是真的吗,... 据了解!wpk辅助器是真的吗,智星德州有脚本吗,确实存在有挂(有挂技术)1)智星德州有脚本吗免费钻石...
网友热议!wepoker是不是... 网友热议!wepoker是不是有人用挂,德普辅助app,其实真的有挂(有挂透明挂)1、打开软件启动之...
第三方技巧!aapoker安装... 第三方技巧!aapoker安装包怎么使用,德扑圈有透视吗,原来确实有挂(有挂方法)德扑圈有透视吗能透...
第三方辅助!werplan透视... 第三方辅助!werplan透视挂,德扑圈透视挂,原来是真的有挂(真实有挂)1、点击下载安装,德扑圈透...
2026版技巧!hhpoker... 2026版技巧!hhpoker有没有辅助,德普辅助软件,好像是真的有挂(新版有挂)1、任何德普辅助软...
日前!xpoker辅助控制,智... 日前!xpoker辅助控制,智星德州有脚本吗,总是确实有挂(竟然有挂)1)智星德州有脚本吗免费钻石:...
黑科技教程!wepoker是不... 您好,德扑之星透视软件免费入口官网这款游戏可以开挂的,确实是有挂的,需要了解加去威信【1367043...
最终!wpk辅助器是真的吗,德... 最终!wpk辅助器是真的吗,德普之星透视,竟然是有挂(发现有挂)德普之星透视透视方法中分为三种模型:...