0

I want to create an URL like:

http://localhost:3000/home/#/student/studentId=63

or

http://localhost:3000/home/#/student:studentId=63

without using the '?' character.

But the following code is not creating an URL like the ones above:

.state('home.student', {
        url: 'student?courseId&studentId',
        controller: 'StudentController',
        templateUrl: 'student.view.html',
      })

This state creates an URL like:

http://localhost:3000/home/#/student?studentId=63

.state('home.student', {
        url: 'student/:courseId/:studentId/',
        controller: 'StudentController',
        templateUrl: 'student.view.html',
      })

This state create url like http://localhost:3000/home/#/student/63

Could someone please tell me how to create an URL like:

http://localhost:3000/home/#/student/studentId=63

or

http://localhost:3000/home/#/student:studentId=63

In the above URLs the '?' character is not needed.

rbento
  • 9,919
  • 3
  • 61
  • 61
Guest
  • 415
  • 8
  • 19
  • 1
    Why would you want to create non-standard URLs like that? You'll probably have to do alot of extra work. BTW, you are talking about *ui-router*, right? – stholzm May 16 '16 at 07:41
  • [I think your answer is write there](http://stackoverflow.com/questions/33181532/why-give-an-abstract-true-state-a-url) – Ariful Haque May 16 '16 at 08:04

2 Answers2

0

For url like http://localhost:3000/home/#/student/studentId=63

you coul try:

.state('home.student', {
        url: 'student/?studentId',
        controller: 'StudentController',
        templateUrl: 'student.view.html',
      })
mtamma
  • 533
  • 4
  • 6
0

The url is like a pattern, so just write the pattern you want. For [your base url for the 'home' state]/student/studentId=63 :

$stateProvider.state('home.student', {
  url: '/student/studentId=:studentId',
  controller: 'StudentController',
  templateUrl: 'student.view.html',
})
evsheino
  • 2,147
  • 18
  • 20