搜尋

首頁  >  問答  >  主體

angular.js - angularJs ngRoute怎麼在路由傳遞空字串及用ng-switch取得

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

在路由config裡面type的其中一個可能是為空值,不同的值跳到的頁面展示效果不一致,現在在頁面用函數:
ng-click="jump('/asset/ ')"可以傳遞空字串,但對應的跳到頁面後路由為:#/asset/%20,在後面自動加了%20, 然後在ng-switch="type" 裡面使用ng-switch-when=" ",卻顯示不出對應的效果,也嘗試過ng-switch-when="%20",都無法跳到符合的樣式。請問該怎麼達到這個效果?

phpcn_u1582phpcn_u15822861 天前624

全部回覆(2)我來回復

  • phpcn_u1582

    phpcn_u15822017-05-15 17:10:43

    預設即為空,不需要特地加上一個 空格符 來實現

    回覆
    0
  • 阿神

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

    $locationProvider.hashPrefix('');

    這是因為新版本的ngroute加了感嘆號引起的 幹掉他就好了

    回覆
    0
  • 取消回覆