0

I am working with ui-router and have several states defined. On one of my views I have a form where a user can add a 'team' to the view. I have a button for each team to view additional details on that team. What I am trying to do is set it up so that when I click on that button the team view comes up with the URL like /#/teams/yankees for example.

I may just not be looking in the right places or know the exact term for this, but I have not been able to figure it out so far.

Below is a snippet of what I currently have in my app.js for this portion.

app.config(
    ['$stateProvider','$urlRouterProvider', 
    function($stateProvider, $urlRouterProvider){
    $urlRouterProvider.otherwise('/');
    .state('teams', {
        url: '/teams',
        templateUrl: './templates/main/teams.html',
        controller: 'teamsCtrl'
    })
    .state('teams/{{ team.title }}', {
        url: '/teams/{{ team.title }}',
        templateUrl: './templates/main/team.html',
        controller: 'topicCtrl'
    })

Whenever I click on the button now to go to /#/teams/yankees I end up being routed by $urlRouterProvider.otherwise('/'); Can someone point me in the right direction?

1 Answer 1

1

It would be helpful to know what your links look like... are you using ui-sref? Typically url attributes look more like this like this:

.state('teams/{{ team.title }}', {
    url: '/teams/:title',
    templateUrl: './templates/main/team.html',
    controller: 'topicCtrl'
})

rather than the {{}}

Sign up to request clarification or add additional context in comments.

2 Comments

That was actually it! I can't believe it was that simple of a change. Well done sir!
glad to be of service :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.