search

Home  >  Q&A  >  body text

angular.js - Routing address passes optional parameters in angularjs1

How to pass optional routing parameters in routing in angular1:

For example: www.test.com Pass optional route parameter id www.test.com/#/test/id in config:

$routeProvider.when('/test/:id',{
         templateUrl: 'test.html',
         controller: 'testCtrl'
})

If you write the id according to the above code, you must pass it. Once the id is empty, the corresponding page will not be displayed. Is there any way to pass this value as empty or optional

世界只因有你世界只因有你2861 days ago575

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-15 17:15:10

    I kind of forgot about it, but I usually add it?

    $routeProvider.when('/test/?:id',{
             templateUrl: 'test.html',
             controller: 'testCtrl'
    })

    reply
    0
  • Cancelreply