Skip to content

[HELP] Support for angular? #159

Answered by aschoerg
woeterman94 asked this question in Q&A
Discussion options

You must be logged in to vote

What I found as a workaround but I am not sure, if this is a desirable method ...

In your component.ts, implement AfterViewInit and run a query selector. The selector ensures it only runs on not initialized inputs. @ts-ignore is needed, because this lib adds a function to all elements, but ts does not know about this.

export class YourComponent implements AfterViewInit {
  ngAfterViewInit(): void {
    // @ts-ignore
    document.querySelectorAll('*:not(div.toggle)>input[type="checkbox"][data-toggle="toggle"]').forEach(i => i.bootstrapToggle());
  }
}

And in my angular.json file, I have included:

{
  "projects": {
    "Frontend": {
      "architect": {
        "build": {
          "options":…

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by palcarazm
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
help wanted Extra attention is needed
4 participants
Converted from issue

This discussion was converted from issue #128 on April 21, 2024 17:45.