当ui日历首先隐藏然后显示时发生

Issue when an ui-calendar is first hid and then showed

本文关键字:显示 然后 隐藏 ui 日历      更新时间:2023-09-26

我遇到了一个奇怪的问题ui-calendar当你的日历首先隐藏,然后显示。在Github上,遇到了类似的问题,但使用选项卡(我不使用):https://github.com/angular-ui/ui-calendar/issues/28

我编辑了一个JsFiddle来明确这个问题:http://jsfiddle.net/fECuY/20/

<div ng-show="test">
      <div ng-controller="MainCtrl" ui-calendar="calendar" config="uiconfig.calendar" ng-model="events"></div>
</div>

如果你点击按钮,第二个日历应该显示,但它的'头'只是渲染。如果我们试图在变量(链接到ng-show属性)被更改时呈现日历,那么ng-show还没有更新,因此即使使用DOM操作,也无法在该元素上调用fullCalendar()。

那么,当我想要显示日历时,我如何才能正确地呈现日历呢?

问题在于ng-show的工作方式。它实际上是使用display: none来隐藏元素。这就产生了如何显示日历的问题。解决方案是使用ng-if代替,它将在它为真时生成日历。