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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With