0

I know I can trigger the ripple effect on divs, like in this demo

But this only works for the first element with the ripple directive. If I have two elements with the directive, like this:

<div matRipple #rippleOne>
   rippleOne
</div>
<div matRipple #rippleTwo>
   rippleTwo
</div>

Now how do I only trigger the second ripple? Tried this:

@ViewChild(MatRipple)
rippleTwo: MatRipple;
...
this.rippleTwo.launch({});

Which won't work.

Also

@ViewChild('rippleTwo')

won't work. What is the correct way?

Flores
  • 8,226
  • 5
  • 49
  • 81

1 Answers1

3

read option should do the trick:

@ViewChild('rippleTwo', { read: MatRipple })
rippleTwo: MatRipple;

See also:

yurzui
  • 205,937
  • 32
  • 433
  • 399