Я хочу сделать что-то подобное в AngularJS с этим Jquery код
x = $(this).next().next().val();
alert(x);
HTML-код:
<span ng-click="ajax_update_button()" class="glyphicon glyphicon-pencil" style="cursor: pointer; color: red;"></span>
<span ng-click="ajax_delete([[ x.id ]])" style="cursor: pointer; color: red;">X</span> -----
<span>[[ x.name ]]</span>
угловой Javacript является:
var StudentListSystem = angular.module('StudentListSystem', ['ngRoute']);
StudentListSystem.controller('SectionFormController', function($scope, $http){
$scope.ajax_delete = function(id){
// alert(id);
$http.delete('http://127.0.0.1:8000/api/v1/section/'+id)
.then(function(response){
$scope.Notifications = true;
$scope.Deleted = response.data;
// alert(JSON.stringify(response));
$http.get('http://127.0.0.1:8000/api/v1/section/')
.then(function(response){
$scope.Sections = response.data;
});
}, function(response){
$scope.Notifications = true;
$scope.Errors = response.data;
});
}
$scope.ajax_update_button = function(event){
x = $(this).next().next().text();
$(this).next().next().html("<input type='text' value='"+x+"'>");
}
});
Главный вопрос заключается в том, что я ищу альтернативу $ (this) от jquery до angularjs
Что вы хотите делать с этим? Просто для доступа к значению span? – Satpal
Многие вещи, такие как изменение текста следующих двух пролетов –