javascript - Angular Material Datepicker toggle icon click event - Stack Overflow

Is it possible to somehow catch click event on angular material datepicker toggle icon? I want trigger

Is it possible to somehow catch click event on angular material datepicker toggle icon? I want trigger function foo().

My implementation looks like:

          <mat-form-field class="example-full-width">
            <input matInput [matDatepicker]="picker" placeholder="Date">
            <mat-datepicker-toggle matSuffix [for]="picker" (click)="foo()"></mat-datepicker-toggle>
            <mat-datepicker #picker></mat-datepicker>
          </mat-form-field>

I have already tried put (click)="foo()" to mat-datepicker-toggle and mat-datepicker element but event not triggered.

Is it possible to somehow catch click event on angular material datepicker toggle icon? I want trigger function foo().

My implementation looks like:

          <mat-form-field class="example-full-width">
            <input matInput [matDatepicker]="picker" placeholder="Date">
            <mat-datepicker-toggle matSuffix [for]="picker" (click)="foo()"></mat-datepicker-toggle>
            <mat-datepicker #picker></mat-datepicker>
          </mat-form-field>

I have already tried put (click)="foo()" to mat-datepicker-toggle and mat-datepicker element but event not triggered.

Share Improve this question asked Feb 11, 2020 at 13:38 DuFuSDuFuS 3711 gold badge5 silver badges15 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

Use opened and closed event emitter provided by angular date picker ponent to listen open and close of calander ponent.

<mat-form-field class="example-full-width">
            <input  matInput [matDatepicker]="picker" placeholder="Date">
            <mat-datepicker-toggle            
             matSuffix [for]="picker" (click)="foo()"></mat-datepicker-toggle>
            <mat-datepicker 
            #ref
            (opened)="toggle(ref)"
            (closed)="toggle(ref)"
            #picker></mat-datepicker>
</mat-form-field>

Example

Try to (focus)="foo()" instead of (click)="foo()"

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742301401a4418097.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信