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

LouieV
  • 1,032
  • 2
  • 15
  • 28

1 Answers1

1

you can use $routeParams

Please see at; $routeParams

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

Community
  • 1
  • 1
Teoman shipahi
  • 47,454
  • 15
  • 134
  • 158
  • I know I can use $routeParams but I need it in a new route and doin something like `.when('/accounts-one/:accountId', {templateUrl: , controller: ` I get SyntaxError: Unexpected token < at eval (native) – LouieV Jul 07 '14 at 19:14