Why is this answer downvoted? It seems to work (you can try it out on the stackblitz link provided.). Is there any reason?