Search code examples
javascriptangularjsstatementsui-sref

AngularJS $stateparams


I have three button on main page.

-Naruto 300 // When I hover on button its says "oku/300".
-Bleach 300 // When I hover on button its says "oku/300".
-One Piece 450 // When I hover on button its says "oku/450".

But I want "oku/Naruto/300". How can i do that?

App.js

$stateProvider
.state('oku', {
url: "/oku/:id",
views: {
"viewC": { templateUrl: "oku.html",
            controller: "nbgCtrl",},
},
   resolve: {
     alData : function(NBG, $stateParams, $filter){
        return NBG.adlar.then(function(res){
            return $filter('filter')(res.data, {klasor: $stateParams.id}, true)[0];
        });
   }
 }
 })

Related index.html part.

<a ui-sref="oku({id:manga.lastchapter})" class="waves-effect waves-light btn">{{manga.lastchapter}}</a>

I changed link to:

<a ui-sref="oku/{{manga.name}}({id:manga.lastchapter})"

But it wont work.


Solution

  • You want to add another path segment and param:

    Config:

    .state('oku', {
        url: "/oku/:name/:id",
    

    HTML

    <a ui-sref="oku({id:manga.lastchapter, name:manga.name})">