Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically add toggle in ionic angularJS

I am trying to add dynamically toggle in ionic but it does not work. please help me.

if (maxScore==1){
angular.element(document.getElementById(objItem)).html(objItem + '<div> <ion-toggle ng-change="pushNotificationChange(this)"></ion-toggle></div></div>');   
}

Thanks in advance.

like image 517
Umer Younas Avatar asked Mar 06 '26 03:03

Umer Younas


1 Answers

You can not add dynamicly into angularJS HTML Code just like that.

In order to make it work , you need to compile it by using dependency $compile

If you want to bypass that you just add into your HTML code your toogle code with a condition

<div ng-if="maxScore===1"> <ion-toggle ng-change="pushNotificationChange(this)"></ion-toggle></div></div>

into your controller, just change your code that instanciate maxScore to $scope.maxScore

like image 132
aorfevre Avatar answered Mar 07 '26 16:03

aorfevre



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!