文章详情页
angular.js - angularJs ngRoute怎么在路由传递空字符串及用ng-switch取得
浏览:119日期:2024-09-24 09:30:57
问题描述
.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',都无法跳转到匹配的样式。请问应该怎么才能实现这个效果?
问题解答
回答1:默认即为空,不需要特地加一个 空格符 来实现
回答2:$locationProvider.hashPrefix(’’); 这是因为新版本的ngroute加了感叹号引起的 干掉他就好了
相关文章:
排行榜
