[英]Error Access-Control-Allow-Origin With Angular.js and API with Laravel5.1
i am developing an application with Laravel 5.1 and Angular.js and when i try to connect i have the next error: 我正在使用Laravel 5.1和Angular.js开发应用程序,当我尝试连接时遇到下一个错误:
XMLHttpRequest cannot load http://localhost:8000/university. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access.
I have the next code in angular: 我有角度的下一个代码:
angular.module('clientApp')
.controller('UniversityCtrl', function ($scope, $resource) {
Universities = $resource("http://localhost:8000/university/:id",{id: "@id"});
$scope.Universities = Universities.query();
});
My view: 我的观点:
<table>
<thead>
<tr>
<th>University</th>
<th>Address</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="Universities in University">
<td>{{University.name}}</td>
</tr>
</tbody>
</table>
and my code of Laravel: 和我的Laravel代码:
public function index()
{
$universities = university::all();
return response()->json(
$universities->toArray()
);
}
Thanks :D 感谢:D
单个通过barryvdh安装此软件包
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.