Angular 2 and php Laravel 5 example


Angular 2 and php Laravel 5 example

我正试图找到一个关于如何将Laravel与Angular 2一起使用的具体示例。尝试使用谷歌,但没有成功。此外,我想知道当使用组件注释对象密钥templateUrl时,它是否可以接受php扩展而不是html。

人们一致认为,最好将Angular 2用作独立的前端,并让Laravel充当API。

也就是说,我确实找到了这本指南,它明确地将两者联系在一起。我不确定它是否能回答你的具体问题,但它可能会帮助你开始。祝你好运

在将所有路由器设置在带角度的前侧之后。

此路由适用于Angular2,应位于所有其他后端路由之后只需将其保持在底部(laravel5.2中的route.php在laravel5.3中的web.php

Route::get('/{any}', function ($any) {
return view('welcome');
})->where('any', '.*');
$scope.refresh = function () {
    $http({
      url: '',
      method: "GET"
    }).success(function (data) {
      $scope.trans = data.transactions; 
     console.log($scope.trans);
    }).error(function (data) {
      console.log('Error');
    });
 }
$scope.refresh(); // We call the function on initialization to load the feed.