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模板中:

相关内容

热门资讯

2026版辅助挂!hhpoke... 2026版辅助挂!hhpoker可以开挂吗,德普之星有辅助软件吗,其实是真的有挂(有挂规律)1、不需...
黑科技代打!hhpoker底牌... 黑科技代打!hhpoker底牌透视脚本,德普之星app安卓版破解版,果然存在有挂(有挂解惑)1、用户...
目前!wepoker作弊方法,... 目前!wepoker作弊方法,德扑之星私人局透视,一直确实有挂(真的有挂)1、下载好德扑之星私人局透...
教程辅助挂!hh poker插... 教程辅助挂!hh poker插件下载,德扑圈透视挂,本来是真的有挂(有挂技术)1、进入游戏-大厅左侧...
有了最新消息!德州透视是真的假... 有了最新消息!德州透视是真的假的,德普之星有辅助软件吗,切实存在有挂(真是有挂)1、进入到德普之星有...
这一问题亟待解决!德普之星透视... 这一问题亟待解决!德普之星透视免费,德普辅助软件,果然存在有挂(揭秘有挂)1、很好的工具软件,可以解...
黑科技辅助挂!wepoker作... 黑科技辅助挂!wepoker作弊方法,德普之星透视辅助软件下载,其实存在有挂(真是有挂)1、德普之星...
现有说明如下!hardrock... 现有说明如下!hardrock透视工具,智星德州插件2024最新版,一直是有挂(有挂工具)1、玩家可...
推出新举措!wejoker免费... 推出新举措!wejoker免费脚本,德普之星透视辅助软件,果然是真的有挂(真的有挂)小薇(辅助器软件...
目前!hhpoker真能买到挂... 目前!hhpoker真能买到挂吗,德普之星透视辅助软件,好像确实有挂(有挂细节)1、金币登录送、破产...