Angularjs1 pass on the parameters by url, not ui-self.

Angularjs1 pass on the parameters by url, not ui-self.

2017-06-07 / 0 评论 / 113 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2021年10月27日,已超过1121天没有更新,若内容或图片失效,请留言反馈。

Currently, if you are using angularjs router, and use ui-self to link your destination page in html, and you can pass on the parmaters by ui-self. However, if right click and 'open link in new tab', the parameters in ui-self will be missing, and it can't pass on. what we can do?

first let's browse a code:
1. file 1: audience.js

$stateProvider.state('audiencesCreate', {
        url: '/audience/create-audience',
        params: {folder: null, type: null},
        templateUrl: 'templates/audiences/audiences.create.html'
    });

file 2: checkout.html

<div class="col-md-12">
    <ul>
        <li ng-if="audiencePermission.digital">
            <a ui-sref="audiencesCreate({type:'digital'})">Start a New Digital Audience</a>
        </li>
        <li ng-if="audiencePermission.tv">
            <a ui-sref="audiencesCreate({type:'tv'})">Start a New TV Audience</a>
        </li>
        <li ng-if="audiencePermission.firstParty">
            <a ui-sref="audiencesUpload">Start a New Upload (Audience Onboard)</a>
        </li>
        <li>
            <a ng-click="open(audienceID)">View this Distribution</a>
        </li>
        <li>
            <a href ui-sref="audiencesSaved">Browse Saved Audiences</a>
        </li>
    </ul>
</div>

Question: It can't open link in new tab.

Solution: change js code for url with add '?parameter'
The only difference is now we have the parmeter in url when open digital or tv.

$stateProvider.state('audiencesCreate', {
        url: '/audience/create-audience?type?folder',
        params: {folder: null, type: null},
        templateUrl: 'templates/audiences/audiences.create.html'
    });

0

评论 (0)

取消