How does angularjs use ngRoute routing to pass optional parameters?
//下面是路由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>
There are now 6 html pages. Click to jump to the asset page. One of the passed parameters must be empty. The remaining 5 pages pass parameter type of 1-5.
The jump() function passes a null value. What should I write to jump to the asset page?
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