Chcę usunąć jquery z mojej aplikacji .. Ale chcę zastąpić $ .each w angularjs ... Jak mogę pętli wokół elementów dom? Tutaj dodałem mój kod .. Chcę, aby przekształcić go w angularjs z jQueryJaka jest alternatywa dla jquery każdego w angularjs?
app.directive('activeu', function($location) {
return function ($scope, element, attrs) {
var menuMain = $scope.$parent.menuMain;
var fullpath = $location.path().split('/');
var current = fullpath[2];
setTimeout(function() {
$(".nav li a").each(function() {
if ($(this).attr('href') == '#!/page/' + current) {
$(this).parent().addClass('active');
$(this).closest('li.root-li').addClass('active');
if ($(this).closest('li.parent').length > 0) {
$(this).closest('li.parent').addClass('active');
}
}
});
$(".nav li a").on('click', function() {
current = $(this).attr('href');
$("#pages-menu .navigation li").each(function() {
if ($(this).hasClass('active')) {
$(this).removeClass('active');
}
});
$(".nav li a").each(function() {
if ($(this).attr('href') == current) {
$(this).parent().addClass('active');
$(this).closest('li.root-li').addClass('active');
if ($(this).closest('li.parent').length > 0) {
$(this).closest('li.parent').addClass('active');
}
}
});
});
}, 500);
};
});
to daje mi jak var htm = "Login" .. Mogę uzyskać do niego dostęp jak htm.href .. ale zamiast tego jeśli chcę uzyskać do niego dostęp, tak jak htm.attr ('href'), w jaki sposób Czy mogę to zrobić?? – Amb
@amss Myślę, że musisz udostępnić trochę więcej szczegółów, jakiego rodzaju dane próbujesz iterować i jaki jest pożądany wynik –
Edytowałem moje pytanie ... Chcę zastąpić jquery każdy do kątowego. Dla każdego – Amb