Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 and BootStrap-Toggle

Tags:

angular

I'm trying to use Bootstrap-Toggle in a Angular2 project and I can't get it working.

I did some debugging and I it see properly displaying but after all the initialization occurs it goes back to a normal checkbox.

It appears the problem has to due with Bootstrap-Toggle adding elements directly to the DOM.

How can I get Bootstrap-Toggle working in Angular2?

Bootstrap-Toggle checkbox

like image 706
spottedmahn Avatar asked Sep 25 '26 10:09

spottedmahn


1 Answers

you need to initialize it with java script like that in ngOninit() in your component relative to that template

ngOninit(){
  $("#toggleId").bootstrapToggle();
}
like image 53
Samir Ghoneim Avatar answered Sep 28 '26 01:09

Samir Ghoneim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!