0
在Angular中有沒有一種方法可以訪問被點擊的元素類型?我在jQuery中有以下幾個方面,它工作正常,麻煩的是我不知道如何做一個Angular項目中的等價物,我被問到過。在Angular中訪問點擊元素的類型
// Click action
$(".contactlist").on("click", function(e) {
if (!$(e.target).is(':checkbox') && !$(e.target).is("li:nth-child(1)")) {
var token = $(this).data('token');
window.location.href = "XYZ.php?page=contacts&token=" + token;
}
});
我該如何修改這個Angular事件處理程序來像上面的jQuery一樣工作?
$scope.eventHandler = function(data) {
window.location.href = "XYZ.php?page=contacts&token=" + data.token;
};
像這樣的事情????
$scope.eventHandler = function(data) {
if (!$(this.target).is(':checkbox') && !$(this.target).is("li:nth-child(1)")) {
window.location.href = "XYZ.php?page=contacts&token=" + data.token;
}
};
的HTML
<li><input type="checkbox" class="check" data-token="{{data.token}}" name="addselect[]"></li>
您是否包含jQuery? '$(this.target)'是jQuery,而不是Angular。 – putvande
是包含jQuery庫。 – Rob