将参数从URL传递给laravel中的Angular JS控制器

时间:2017-12-06 02:11:15

标签: angularjs laravel laravel-5 angularjs-directive angularjs-scope

如何从fixassid url route history获取angular js controller getpc_his并将其传递给controller中的<a href="{{url('history/'.$get_history_pc->fixass_id)}}">( View History )</a>

我的刀片模板

Route::get('history/{fixassid}',function (){
        return view('assetmanagement.history.pchistory');
    });
Route::get('/api/v1/pchists/{fixassid}','HistoryController@getpc_his');

我的路线

var app = angular.module('angtable', ['angularUtils.directives.dirPagination'])
    .constant('API_URL', 'http://testing/mypro/public/api/v1/');
app.controller('pchistory', function ($scope, $http, API_URL) {
    $scope.currentPage=1;
    $scope.itemsPerPage=10;

    $scope.sizes = [ {code: 0, name: '5'}];
    $scope.update = function() {
        //console.log($scope.item.code, $scope.item.name)
        $scope.itemsPerPage= $scope.item.name;
    }

    //retrieve employees listing from API
    $http.get(API_URL + "pchists/"+ "fixassid")
        .success(function (response) {
            $scope.pchists = response;
        });

    $scope.sort = function (keyname) {
        $scope.sortKey = keyname;   //set the sortKey to the param passed
        $scope.reverse = !$scope.reverse; //if true make it false and vice versa
    }
});

My Angular JS

public function getpc_his($fixassid){       
        $history=DB::table('psl_tbl_his')           
            ->where('fixass_id',$fixassid)
            ->get();
        return $history;
}

我的控制器

opcache_reset();

0 个答案:

没有答案