Uygulamamdan jquery kaldırmak istiyorum .. Ama ben angularjs içinde $ .each yerine ... Nasıl dom elemanları etrafında loop edebilirsiniz? İşte benim kod eklemiş .. benAngularjs'de jQuery için alternatif nedir?
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);
};
});
onun gibi veren var htm = "Login" .. Ben htm.href gibi girebilirsiniz .. ama bunun yerine htm.attr ('href') gibi erişmek istiyorsanız, Nasıl bunu yapabilir miyim?? – Amb
@amss Biraz daha fazla ayrıntıyı yinelemeye çalıştığınız veriyi yinelemeye çalışıyorum ve istediğiniz çıktı nedir –
Sorumu düzenledim ... jquery'yi her seferinde angular.forEach – Amb