search

Home  >  Q&A  >  body text

angular.js - How to modify the url format of angular

http://localhost/shop#/item/1000
I want to change it to http://localhost/shop#item-1000
I use $stateProvider


  .state('item', {
        url: '/item/:id',
        templateUrl: "/ionic/templates/item.html",
        controller:'ItemShowController'
      })

The above has also been changed. Changing it to url: 'item-:id', is useless

PHP中文网PHP中文网2828 days ago578

reply all(1)I'll reply

  • 黄舟

    黄舟2017-05-15 17:04:49

    First generally #之前的路由是后端提供的,#之后的路由是由Angular控制的;#表明整个应用使用的是Angulardefault hash routing. If you want to change it to what you want, you can try this:

    .state('item', {
            url: '/item-{id}', // 这里这样写路由
            templateUrl: "/ionic/templates/item.html",
            controller:'ItemShowController'
          })

    This should be fine

    reply
    0
  • Cancelreply