Problem passing parameters through url using angularjs

0

I have a template here that uses angularJS and its route system is as follows

.state('app.produto', {
                  url: '/produto',
                  templateUrl: 'tpl/detProdutos.php',
                  // use resolve to load other dependences
                  resolve: {
                      deps: ['uiLoad',
                        function( uiLoad ){
                          return uiLoad.load( ['js/app/produto-calc.js',
                                               JQ_CONFIG.moment] );
                      }]
                  }
              })

and in html it looks like this:

<a ui-sref="app.produto" class="pull-left thumb-md avatar b-3x m-r">

And I needed to go through the URL of the product ID but I do not know how I can do it in the angle ... does anyone have any idea how I can do this?

    
asked by anonymous 24.10.2016 / 00:45

1 answer

1

You should first declare that the url expects a parameter, like this:

url: '/produto:idProduto', //ou /produto/:idProduto

Then you pass this parameter over the link as an object, like this:

ui-sref="app.produto({idProduto: $scope.idProduto})" //o "idProduto" definido aqui deve ser sempre igual ao definido no 'state'

Remembering that this is just a way to use uiRouter parameters, here you can read more about it.

    
24.10.2016 / 02:11