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

前端 未结 2 1807
慢半拍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:40

    The path in ngRoute path can contain named groups starting with a colon and ending with a star like :name* , All characters are eagerly stored in $routeParams under the given name when the route matches.

    For example, routes like : /color/:color/largecode/:largecode*/edit

    For this sample URL : /color/brown/largecode/code/with/slashes/edit

    And extract:

    color: brown

    largecode: code/with/slashes.

    So in your case it the Route will be

    .when('/provider/:id*\/collectionName/:collectionName*\', {                            
            templateUrl: 'templates/provider/form.html',
            controller: 'ProviderController',
            controllerAs: 'provider'
        })   
    

    This will ensure that even if there are special characters and forward slashes in your resultant href link you are redirected to proper controller and page...

提交回复
热议问题