Angularjs 从Angular/Ionic应用程序向Laravel API发布数据时出现问题

Angularjs 从Angular/Ionic应用程序向Laravel API发布数据时出现问题,angularjs,laravel,post,eloquent,Angularjs,Laravel,Post,Eloquent,我正在尝试将数据从angular(Ionic mobile app)发布到远程Laravel 5 REST API。这在使用Postman发布数据时有效,但在我的一生中,当尝试通过角度前端时,无法将其保存到数据库中。这是我的角度代码以及用于保存数据的Laravel控制器 控制器/authentication.js var app = angular.module('myApp.controllers.authentication', []); app.controller('LoginCtrl

我正在尝试将数据从angular(Ionic mobile app)发布到远程Laravel 5 REST API。这在使用Postman发布数据时有效,但在我的一生中,当尝试通过角度前端时,无法将其保存到数据库中。这是我的角度代码以及用于保存数据的Laravel控制器

控制器/authentication.js

var app = angular.module('myApp.controllers.authentication', []);

app.controller('LoginCtrl', function ($scope, $state, $ionicLoading, AuthService) {
    $scope.loginInstagram = function() {
        AuthService.loginInstagram()
            .then(function() {
                console.log('Signed In Insta');
                $state.go("tab.home");
            });
    }
});
var app = angular.module('myApp.services.authentication', []);

app.service('AuthService', function ($q, $http, $cordovaOauth, $ionicPopup) {
     var self = {
          'loginInstagram': function() {
            var d = $q.defer();

            $cordovaOauth.instagram('42e2f60b94e1487db4617a48a7000453', [], {})
                .then(function(result) {
                     console.log("Response Object -> " + JSON.stringify(result));


                    // save the access token
                    var data = { instagram_access_token: result.access_token };

                          $http.post("http://localhost:8000/api/user/signupInstagram", data).success(function(data, status) {
                           console.log(data);
                          });   
                }, function(error) {
                    console.log("Error -> " + error);
                });

               return d.promise;

        }
     };

     return self;
});
服务/身份验证.js

var app = angular.module('myApp.controllers.authentication', []);

app.controller('LoginCtrl', function ($scope, $state, $ionicLoading, AuthService) {
    $scope.loginInstagram = function() {
        AuthService.loginInstagram()
            .then(function() {
                console.log('Signed In Insta');
                $state.go("tab.home");
            });
    }
});
var app = angular.module('myApp.services.authentication', []);

app.service('AuthService', function ($q, $http, $cordovaOauth, $ionicPopup) {
     var self = {
          'loginInstagram': function() {
            var d = $q.defer();

            $cordovaOauth.instagram('42e2f60b94e1487db4617a48a7000453', [], {})
                .then(function(result) {
                     console.log("Response Object -> " + JSON.stringify(result));


                    // save the access token
                    var data = { instagram_access_token: result.access_token };

                          $http.post("http://localhost:8000/api/user/signupInstagram", data).success(function(data, status) {
                           console.log(data);
                          });   
                }, function(error) {
                    console.log("Error -> " + error);
                });

               return d.promise;

        }
     };

     return self;
});
app/Http/Controllers/userscocontroller.php

<?php

namespace App\Http\Controllers;

use Input;
use Request;

use App\Http\Requests;

use App\Http\Controllers\Controller;
use App\User;

class UsersController extends Controller
{
    // Gets all users in the users table and returns them
    public function index()
    {
        $users = User::all();

        return $users;
    }

    public function signupInstagram() {
        $user = new User();

        $user->instagram_access_token = Input::get('instagram_access_token');

        $user->save();
    }
}

控制台中有错误吗?我想这是CORS的问题。修正了这个