I;m having Jquery code that adds class dynamically on function call and I'm passing argumaents based on different conditions.
function setClasses(index, steps) {
$(".step-wizard ul li:lt(" + index + ")").each(function () {
$(this).addClass("done");
});
$(".step-wizard ul li:eq(" + index + ")").addClass("active")
var p = index * (100 / steps);
$("#prog").width(p + '%');
}
setClasses(3, 4);
Since I'm using typescript and angular(1.5.6)I wanted to convert the above code to function using angular's built in DOM manipulation functions.
Below is the one that I tried :
function setClasses(index,steps) {
let myEl1 = angular.element(document.querySelector('.step-wizard ul li:lt'));
var myEl2 = angular.element(document.querySelector('.step-wizard ul li:eq'));
myEl1.addClass('done');
myEl2.addClass('visited');
let p = index * (100 / steps);
myEl2.setWidth(p + '%'); //setWidth is not a angular.element property
}
setClasses(3, 4);
I'm not sure how can I add the below part and also to set the width:
$(".step-wizard ul li:lt(" + index + ")").each(function () {
$(this).addClass("done");
});
Please suggest some good conversion techniques for DOM manipulation using angular built in functions Reference(angular.element)
indexvalue? you are just passing a single value but repeating aseachLoading...........3asindexvalue? Can you explain the last code of your question? Is that adding classdoneto first threelielements?