Внутренняя ошибка сервера при подключении Laravel и Angulars - PullRequest
0 голосов
/ 10 февраля 2019

Я хочу разработать простой внешний интерфейс AngularJS и внутренний интерфейс Laravel.Я не знаю, почему мой маршрут AngularJS не связан с маршрутом Laravel.Следует упомянуть как GET http://localhost/api/todos Внутренняя ошибка сервера.

Hello.php

<html>
<head>
    <title>Laravel + Angularjs</title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
</head>
<body ng-App>
    <div id="todos" ng-controller="Todoctrl">
    <h3 class="page-header">Todos<small ng-if="remaining()">{{remaining()}} remaining</small>
    </h3>
    <ul  class="unstyled">
        <li ng-repeat="todo in todos">
            <input type="checkbox" ng-model="todo.done">
            {{todo.text}}
        </li>
    </ul>
    </div>
</script>
    <script src="js/app.js">
</script>
</body>
</html>

Todo.php (модель)

<?php

    namespace App;

    use Illuminate\Database\Eloquent\Model;

    class Todo extends Model
    {
        protected $guarderd = [];

    }

API.php

  Route::middleware('auth:api')->get('/user', function (Request $request) {
        return $request->user();
    });
    Route::get('/todos',function(Request $request){
        return $request->user();
    });

app.js
function Todoctrl($scope,$http){
    $http.get('api/todos').success(function(todos){
        $scope.todos = todos;
    });
    $scope.remaining = function(){
        var count = 0;
        angular.forEach($scope.todos,function(todo){
            count == todo.done ? 0 : 1;
        });

    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...