C
C
Cyber_bober2017-02-27 12:17:23
Angular
Cyber_bober, 2017-02-27 12:17:23

How to execute external scripts while routing?

Hello, there is a script like

if(document.querySelector('.someClass')){ animate }

Which is responsible for the animation of elements when loading pages.
If you connect it as an external script
<script src="public/index.js"></script>
, then it will work exactly once. How can I make this script run again when loading states?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman, 2017-02-27
@uaKorona

You need to use functions! Seriously.
They can be called any number of times.

C
Coder321, 2017-03-01
@Coder321

function myAnimate(){
    if(document.querySelector('.someClass')){ animate }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question