나는 laravel + angularjs를 사용하여 완전한 crud를 만들고 있지만 "edit"부분에는 문제가 있습니다. 그것의 내부 서버 오류, 그래서 난 무슨 뜻인지 잘 모릅니다 나는 영어 나쁜 죄송합니다 :( 를 도움이 필요합니다.편집 Laravel + AngularJS
오류 "로컬 호스트/crudtcc/공공/API/V1/colaboradores/editar/3 (500)를 GET (내부 서버 오류) "
자바 스크립트 파일
app.controller('colaboradoresController', function($scope, $http, API_URL) {
$http.get(API_URL + "colaboradores")
.success(function(response) {
$scope.colaboradores = response;
});
$scope.toggle = function(modalstate, id_colaborador) {
$scope.modalstate = modalstate;
switch (modalstate) {
case 'add':
$scope.form_title = "Novo colaborador";
$scope.colaborador = null;
break;
case 'edit':
$scope.form_title = "Dados do colaborador";
$scope.id_colaborador = id_colaborador;
$http.get(API_URL + 'colaboradores/editar/' + id_colaborador)
.success(function(response) {
console.log(response);
$scope.colaborador = response;
});
break;
default:
break;
}
$('#myModal').modal('show');
}
$scope.save = function(modalstate, id_colaborador) {
var url = API_URL + "colaboradores/salvar";
if (modalstate === 'edit'){
url += "/editar/" + id_colaborador;
}
$http({
method: 'POST',
url: url,
data: $.param($scope.colaborador),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(response) {
console.log(response);
location.reload();
}).error(function(response) {
console.log(response);
alert('Um erro ocorreu. Check a log para mais detalhes.');
});
}
$scope.confirmDelete = function(id_colaborador) {
var isConfirmDelete = confirm('Tem certeza que deseja excluir o registro?');
if (isConfirmDelete) {
$http({
method: 'DELETE',
url: API_URL + 'colaboradores/remover/' + id_colaborador
}).
success(function(data) {
console.log(data);
location.reload();
}).
error(function(data) {
console.log(data);
alert('Falha na exclusão');
});
} else {
return false;
}
}
}).;
$http.post(API_URL + 'colaboradores/editar/' + id_colaborador, {YOUR_DATA})
.success(function(response) {
console.log(response);
$scope.colaborador = response;
});
및 매개 변수 당신을 통과 :
노선은
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get("/colaboradores/gercolaboradores",
function() {
return view("/colaboradores/gerenciarcolaboradores");
});
Route::get("/api/v1/colaboradores/","[email protected]");
Route::get("/api/v1/colaboradores/editar/{id_colaborador}","[email protected]");
Route::post('/api/v1/colaboradores/salvar/editar/{id_colaborador}',
'[email protected]');
Route::post('/api/v1/colaboradores/salvar', '[email protected]');
Route::delete('/api/v1/colaboradores/remover/{id_colaborador}', '[email protected]');
?>
정교하게 작성하십시오! 어떤 종류의 오류? 500, 404? 메시지? 웹 콘솔을 사용하십시오! –
HTML을 추가 할 수 있습니까? 또한 적절한 디버깅 정보를 얻으려면 개발자 도구를 사용하십시오. 일반적으로 바로 가기는 ctrl + shift + i입니다. – TiagoRL
죄송합니다. 오류는 "http : // localhost/crudtcc/public/api/v1/colaboradores/editar/3 500 (내부 서버 오류)"입니다. 여기 –