我正在使用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.
我有下一个角度代码:
angular.module('clientApp')
.controller('UniversityCtrl', function ($scope, $resource) {
Universities = $resource("http://localhost:8000/university/:id",{id: "@id"});
$scope.Universities = Universities.query();
});
我的观点:
<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>
和我的Laravel代码:
public function index()
{
$universities = university::all();
return response()->json(
$universities->toArray()
);
}
谢谢:D