请问angularjs使用ngRoute 路由传递可选参数是怎么样的?
//下面是路由config
.config(function ($routeProvider) {
$routeProvider
.when('/asset/:type', {//这里页面需要传递可选参数
templateUrl: 'tpl/asset.html',
controller: 'assetCtrl'
})
.otherwise({
redirectTo: '/home'
});
})
//html页面
<p class="assets" ng-click="jump('/asset')">//**这里点击跳转到asset页面**
<p class="total text-center">总资产(元)</p>
<p class="total-count text-center">{{userAll|currency:''}}</p>
<p class="row detail-assets">
<p class="col-xs-6 text-center border">
<p class="profit">当前收益(元)</p>
<p class="count">{{userAllIP|currency:''}}</p>
</p>
<p class="col-xs-6 text-center">
<p class="profit">累计收益(元)</p>
<p class="count">{{Day_all|currency:''}}</p>
</p>
</p>
</p>
现在有6个html页面的p 点击跳转到asset页面 其中一个传递参数必须是空,其余5个页面传递参数type为1-5,
jump()函数在传递空值的时候应该怎么写才能跳转到asset页面?
Recommended to use angular-ui-route
.when('/asset/:type?'
Add a question mark after it so that the asset page can also receive empty parameters