angular.js - angularJs uses ngRoute url to pass parameters problem
为情所困
为情所困 2017-05-15 17:09:23
0
2
707

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?

为情所困
为情所困

reply all(2)
为情所困

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template