AngularJS : How to pass multiple parameters to controller through ng-href?

前端 未结 2 1788
慢半拍i
慢半拍i 2021-01-06 10:18

I\'ve a table containing edit button to update the record. When I\'m passing single id to ng-href its working fine and opening form page:

E

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-06 10:39

    If you want to use multiple params in ng-href you should also update your route url in app.js.

    when you used multiple parameters in ng-href but no route matching with this route then worked otherwise route that redirect to home.

    you can try it.

    in html:

    Edit
    

    add a route in app.js like

    .when('/provider/:id/collectionName/:cName', {                            
            templateUrl: 'templates/provider/form.html',
            controller: 'YourController'
        });
    

    and in controller need to change like:

     $http.get('/providerlist/'+$routeParams.id +'/collectionName/'+ $routeParams.cName)
     .success(function (response) {
         alert(response);
         $scope.providerList = response;
         $scope.id = response['_id'];
     });
    

    so server side route should be like: /providerlist/:id/collectionName/:cName

提交回复
热议问题