我在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