Hi guys,
I followed documentation to set a popup in my project.
This works well.
But when I call the confirmPopup() function, I’m not in controller (I’m in services.js), so when I define scope: $scope,
I have an obvious $scope is unknown
error.
How do you solve this? Thanks a lot !
Find bellow the full code if you need it.
controllers.js
$scope.confirm_redeem_reward = function(asked_reward) {
RewardModel.displayConfirmRedeemReward(asked_reward)
};
services.js
…
RewardModel.displayConfirmRedeemReward = function(asked_reward) {
var confirmPopup = $ionicPopup.confirm({
title: 'Confirmation',
templateUrl: 'templates/popups/confirm_redeem_reward.html',
scope: $scope,
buttons: [{
text: 'Cncel',
type: 'button-default'
}, {
text: 'OK',
type: 'button-positive',
onTap: function(e) {
RewardModel.useReward(asked_reward.id);
RewardModel.used_reward_or_deal_name = asked_reward.name;
}
}]
});
confirmPopup.then(function(res) {
// Nothing
});
};
confirm_redeem_reward.html
Do you want to redeem the reward :<br/>
{{asked_reward.name}} ?