Angular JS与Laravel 5.3搜索过滤器问题

时间:2017-10-14 01:13:15

标签: angularjs laravel

我正在使用角度js和laravel 5.3开发搜索过滤器。

My Angular JS:

    $scope.search = function() {

    var url = "bssrfilter1";

    $http({
        method: 'POST',
        url: url,
        data: $.param($scope.bssrfilter),
        headers: {'Content-Type': 'application/x-www-form-urlencoded'}
    }).success(function(response) {
        console.log(response);

        $scope.bssrfilter = response;

    }).error(function(response) {
        console.log(response);
        alert('This is embarassing. An error has occured. Please check the log for details');
    });
}

我的Laravel控制器:

 public function filter(Request $request)
{       
    $search = $request->searchkey;

    return $bssr = DB::table('adv')
        ->where('adv.description','like','%'.$search.'%')
        ->orWhere('adv.advtopic','like','%'.$search.'%')
        ->get()
        ->toArray();
}

我的laravel路线:

 Route::post('/bssrfilter1', 'SiteController@filter');

当我第一次提交表单时,它会给我正确的搜索结果。但是,在显示结果后,再次提交搜索表单不会过滤结果。任何解决方案都会有很大的帮助。

0 个答案:

没有答案