How can I catch the Material Datepicker month pagination event?

前端 未结 4 629
天涯浪人
天涯浪人 2020-12-12 01:37

I would like to catch the event that comes from the month \"left\" and \"right\" selection buttons, but I couldn\'t find any documentation about it.

What ev

4条回答
  •  一个人的身影
    2020-12-12 02:13

    the only way I've found is, (idea from onthecode) in open, check for querySelectorAll of the buttons. some like

    
      
      
      
      
    
    
      constructor(private renderer: Renderer2) { }
      openCalendar() {
        setTimeout(() => {
          const buttons = document.querySelectorAll
          ('.mat-calendar-previous-button,.mat-calendar-next-button')
          if (buttons) {
            Array.from(buttons).forEach(button => {
              this.renderer.listen(button, "click", (event) => {
                console.log('Arrow button clicked')
              });
            })
          }
        })
      }
    

    see stackblitz

提交回复
热议问题