search

Home  >  Q&A  >  body text

angular.js - How to pass empty string in angularJs ngRoute route and obtain it using ng-switch

  .when('/asset/:type', {//资产详情路由
                templateUrl: 'tpl/asset.html',
                controller: 'assetCtrl'
            })

One of the types in the routing config may be a null value. Different values ​​jump to pages with inconsistent display effects. Now use the function on the page:
ng-click="jump('/asset/ ' )" can pass an empty string, but the corresponding route after jumping to the page is: #/asset/ , with automatically added at the end, and then use ng-switch-when in ng-switch="type" =" ", but the corresponding effect cannot be displayed. I also tried ng-switch-when=" ", but failed to jump to the matching style. How can I achieve this effect?

phpcn_u1582phpcn_u15822814 days ago609

reply all(2)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-15 17:10:43

    It is empty by default, no need to add a space character to achieve it

    reply
    0
  • 阿神

    阿神2017-05-15 17:10:43

    $locationProvider.hashPrefix('');

    This is caused by the new version of ngroute adding an exclamation mark. Just get rid of him

    reply
    0
  • Cancelreply