0

Im using third party splitjs. script will search id of div then run, and it work great when i put element in index.html. But when i put element in component it seem script cant find id of elements? Im missing something? Appreciate any comments.

<body>
    <app-root></app-root>

    <div class="content">
        <div id="red" class="cell"></div>
        <div id="blue" class="cell"></div>
    </div>
    <script>
        Split(["#red", "#blue"], {
            minSize: 0
        });
    </script>
</body>
2
  • github.com/angular-split/angular-split - have you looked into this? this is an angular wrapper for split.js Commented Jul 28, 2020 at 4:52
  • @SmokeyDawson yes i did, thanks man but i want to know why it happens Commented Jul 28, 2020 at 5:04

1 Answer 1

1

PS: Posting as an answer, as the content is too long for a comment.

Why not working

This is because you are running your script from index.html file only, whenever your application loads on the browser very first file which executes is index.html. Till that time neither of your application component gets loaded so script won't be able to find out elements.

How to make it work

You can create one service and add this script code there and call that service after the initial component load, in that way it might be able to find DOM elements.

Sign up to request clarification or add additional context in comments.

2 Comments

do we have another way to apply script for all component?
running a script in a service manner would do the trick i guess, try to make it shared service across the components.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.