Problem passing parameters through the url using Angularjs

Asked

Viewed 516 times

0

Guys I have a template here that uses the Angularjs and his 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 product URL but I don’t know how I do it at the angle... anyone has any idea how I do it?

1 answer

1


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

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

Then you pass this parameter by 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 the uiRouter parameters, here you can read more in that regard.

  • And in this example your ai the ID number goes where?

  • @Alfredolima where it says $Cope.idProduct, just replace it with your product id reference

  • Thank you very much...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.