1

I have some accounts routes:

.when('/accounts', {
    templateUrl: 'views/accounts.html',
        controller: 'AccountsCtrl'
    })
.when('/accounts/:accountId', {
    //templateUrl: 'views/account-details.html', // adding this i get a SyntaxError: Unexpected token < and shows my ng-view within ng-view just weird
    //controller: 'AccountsDetailCtrl'
 })

and going to /accounts/:account uses the account template which is not suited as it has a table that displays all the accounts. I want send it to a new route but at the same time would like to pass the userId as a parameter.

Is there a way to send the app to a new route with url parameters?

EDIT

To clarify some things I understand that I have $routeParams at my disposal when I successfully can send the app to a new route with no errors. But, commented above in the code if I set the template for '/accounts/:accountId' I get an error.

SyntaxError: Unexpected token <
    at eval (native)
    at https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js:2:2620
    at Function.m.extend.globalEval (https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js:2:2631)
    at m.ajaxSetup.converters.text script (https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js:4:26387)
    at Pc (https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js:4:18104)
    at x (https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js:4:21525)
    at b (https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js:4:25897)
    at Object.send (https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js:4:26001)
    at Function.m.extend.ajax (https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js:4:21302)
    at Function.m._evalUrl (https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js:4:22522) <div class="col-md-10 col-md-offset-2 main ng-scope" ng-view=""> 

Im not sure why. All that my account-details.html template has is Hello world

1 Answer 1

1

you can use $routeParams

Please see at; $routeParams

How to use; https://stackoverflow.com/a/11535887/929902

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

1 Comment

I know I can use $routeParams but I need it in a new route and doin something like .when('/accounts-one/:accountId', {templateUrl: <tmplt route>, controller: <ctrl> I get SyntaxError: Unexpected token < at eval (native)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.