我在routes.php文件文件中定義的路線,但是當我做從我的角度應用Ajax請求,我得到這個錯誤定義路線投擲控制器的方法沒有找到laravel 4
{"error":{"type":"Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException","message":"Controller method not found.","file":"C:\\xampp\\htdocs\\tedxph\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controllers\\Controller.php","line":290}}
這是我的路線文件
/*
|--------------------------------------------------------------------------
| Api Routes
|--------------------------------------------------------------------------
*/
Route::group(array('prefix' => 'api'), function() {
//Auth Routes
Route::post('auth/login', '[email protected]');
Route::post('auth/signup', '[email protected]');
/* Persons */
Route::group(array('prefix' => 'people'), function() {
Route::get('{id}', '[email protected]');
Route::get('/', '[email protected]');
});
/* Events */
Route::group(array('prefix' => 'events'), function() {
Route::get('{id}', '[email protected]');
Route::get('/','[email protected]');
});
});
訪問相同的URL (http://localhost/site/public/api/auth/signup)
從鉻休息客戶端應用程序不給任何錯誤,這可能是錯了嗎?
這是從我的控制器的角碼
$rootScope.show('Please wait..registering');
API.register({email: email, password: password})
.success(function (data) {
if(data.status == "success") {
console.log(data);
$rootScope.hide();
}
})
.error(function (error) {
console.log(error)
$rootScope.hide();
})
更加棱角分明代碼
angular.module('tedxph.API', [])
.factory('API', function ($rootScope, $http, $ionicLoading, $window) {
//base url
var base = "http://localhost/tedxph/public/api";
return {
auth: function (form) {
return $http.post(base+"/auth/login", form);
},
register: function (form) {
return $http.post(base+"/auth/signup", form);
},
fetchPeople: function() {
return $http.get(base+"/people");
},
fetchEvents: function() {
return $http.get(base+"/events");
},
}
});
你想POST或GET?因爲您已將它設置爲POST請求。 – Lynx 2014-08-29 19:00:44
其在API.register()方法中使用$ http.post的發佈請求 – MrFoh 2014-08-29 19:02:48