I am using an ng-click in a dropdown to set a value in another dropdown, but need it to be able to be clicked multiple times in case the user needs to change it.
From my understanding, ng-click
should be able to be used multiple times. But I can't get it to perform more than once.
<div class="col-md-3">
<div class="btn-group" uib-dropdown is-open="status.isopen">
<button id="single-button" type="button" class="btn btn-primary btn-lg" uib-dropdown-toggle ng-disabled="disabled">
Campaign <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="single-button">
<li ng-repeat="campaign in int.campaigns">
<a ng-click="int.getPages(campaign.ID)">{{campaign.Name}}</a>
</li>
</ul>
</div>
</div>
And here is my function.
vm.getPages = function(campaignID) {
pageService.getPagesByCampaignId(campaignID)
.then(function(result) {
vm.pages = result.data;
console.log('pages returned');
},
function(result) {
console.log('page return failed');
});
};
I'm a noob so I wouldn't doubt I am missing something simple.
Fixed it inadvertently by adding additional functionality.
I bound the header of the dropdown button to the selected value and now I can continue selecting different options.
vm.getPages = function (campaignID, campaign) {
vm.campaignNameDisplay = campaign.Name;
pageService.getPagesByCampaignId(campaignID)
.then(function (result) {
vm.pages = result.data;
console.log('pages returned');
},
function (result) {
console.log('page return failed');
});
};
and this.
<div class="col-md-3">
<div class="btn-group" uib-dropdown is-open="status.isopen">
<button id="single-button" type="button" class="btn btn-primary btn-lg" uib-dropdown-toggle ng-disabled="disabled">
{{int.campaignNameDisplay}} <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="single-button">
<li ng-repeat="campaign in int.campaigns">
<a ng-click="int.getPages(campaign.ID, campaign)">{{campaign.Name}}</a>
</li>
</ul>
</div>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.