How to pass parameters to $http in angularjs?

前端 未结 4 1487
囚心锁ツ
囚心锁ツ 2020-12-04 23:45

Assume that I have two input boxes with corresponding ng-model as fname and lname. If I call http request as :

$http({method:\'GET\', url:\'/search\', params         


        
4条回答
  •  鱼传尺愫
    2020-12-05 00:20

    Here is a simple mathed to pass values from a route provider

    //Route Provider
    $routeProvider.when("/page/:val1/:val2/:val3",{controller:pageCTRL, templateUrl: 'pages.html'});
    
    
    //Controller
    $http.get( 'page.php?val1='+$routeParams.val1 +'&val2='+$routeParams.val2 +'&val3='+$routeParams.val3 , { cache: true})
            .then(function(res){
                //....
            })
    

提交回复
热议问题