Angular日期选择器未更新
创始人
2024-10-29 05:30:47
0

如果您使用的是AngularJS 1.x版本,请尝试使用以下代码来手动更新日期选择器:

$scope.$watch('date', function(newVal, oldVal) { if (newVal !== oldVal) { $timeout(function() { $('.datepicker').datepicker('update'); }); } });

如果您使用的是Angular 2+版本,请尝试使用以下代码:

import { Component, ViewChild } from '@angular/core'; import { NgbDatepicker } from '@ng-bootstrap/ng-bootstrap';

@Component({ selector: 'app-root', template: }) export class AppComponent { @ViewChild('dp') dp: NgbDatepicker; date = { year: 2017, month: 6, day: 6 };

changeDate() { this.date = { year: 2018, month: 8, day: 8 }; setTimeout(() => { this.dp.navigateTo({ year: this.date.year, month: this.date.month }); }, 1); } }

这将强制日期选择器导航到当前日期。请注意,您需要安装ng-bootstrap模块才能使用NgbDatepicker组件。

相关内容

热门资讯

有玩家发现!hhpoker脚本... 有玩家发现!hhpoker脚本,wepoker安装教程(透视)解密教程(有挂详细)-哔哩哔哩1、点击...
透视有挂!wepoker辅助工... 透视有挂!wepoker辅助工具,xpoker怎么辅助(透视)总结教程(证实有挂)-哔哩哔哩1、用户...
透视真的!佛手在线大菠萝技巧,... 透视真的!佛手在线大菠萝技巧,wejoker透视方法(透视)推荐教程(发现有挂)-哔哩哔哩1、该软件...
今天上午!wepoker有透视... 今天上午!wepoker有透视吗,we-poker辅助软件教程(透视)详细教程(有挂教学)-哔哩哔哩...
最新消息!wepoker永久免... 最新消息!wepoker永久免费脚本,wepoker辅助器下载(透视)专业教程(有挂总结)-哔哩哔哩...
此事备受玩家关注!有哪些免费的... 此事备受玩家关注!有哪些免费的wpk辅助码,xpoker怎么辅助(透视)了解教程(有挂方略)-哔哩哔...
此事引发网友热议!wepoke... 此事引发网友热议!wepoker好友助力码,wepoker怎么买辅助(透视)揭幕教程(确实有挂)-哔...
透视总结!哈糖大菠萝软件下载,... 透视总结!哈糖大菠萝软件下载,htx矩阵wepoker辅助(透视)解迷教程(有挂猫腻)-哔哩哔哩该软...
据目击者称!wepoker私人... 据目击者称!wepoker私人局辅助,wejoker私人辅助软件(透视)关于教程(有挂方式)-哔哩哔...
网友热议!拱趴大菠萝辅助方法,... 网友热议!拱趴大菠萝辅助方法,wepoker有没有插件(透视)揭幕教程(揭秘有挂)-哔哩哔哩1、打开...