angular.js - angularJs使用ngRoute url传递参数问题
为情所困
为情所困 2017-05-15 17:09:23
0
2
648

请问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页面?

为情所困
为情所困

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!