【发布时间】:2018-06-18 17:53:12
【问题描述】:
当我使用 angularjs(frontend) 运行 http-server -o 以使用 symfony (backend) 中的 api 进行登录时,我收到此错误:
加载资源失败:服务器响应状态为 405 (不允许的方法) :8080/app/api/src/AppBundle/Controller/MainController.php
error Impossible d'accéder au serverur.
连接.js
'use strict';
angular.module('myapplication.connection', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/connection', {
templateUrl: 'connection/connection.html',
controller: 'connectionCtrl'
});}])
.controller('connectionCtrl', ['$http', '$scope', function($http, $scope) {
$http.post('api/src/AppBundle/Controller/MainController.php', {formType:'connection'})
.then(function (response) {
$scope.connection = response.data;
}, function(response) {
$scope.connection = "Impossible d'accéder au serveur.";
});
}]);
connection.html(表单)
<div class="content">
<h2>Connexion</h2>
<div>{{ connection }}</div>
</div>
我该如何解决这个错误?
【问题讨论】:
标签: angularjs node.js api symfony