我创建了一个常见的弹出屏幕,它在三个模块中使用,但三个模块有不同的标题。我没有在标题中给出条件,是否可能有人给我解决方案。
此处弹出代码:
function showPopup () {
$scope.data = {};
var myPopup = $ionicPopup.show({
template: '<input focus-me type="text" ng-model="data.expensetype" limit-char limit="15">',
if (vm.usertype === 'Worker') {
title: $translate.instant('{{"wtype_message" | translate}}'),
}
else if (vm.usertype === 'Buyer') {
title: $translate.instant('{{"btype_message" | translate}}'),
}
else if (vm.usertype === 'Expense') {
title: $translate.instant('{{"etype_message" | translate}}'),
}
scope: $scope,
buttons: [
{ text: $translate.instant('{{"pcancel_message" | translate}}') },
{
text: $translate.instant('{{"psave_message" | translate}}'),
type: 'button-positive',
onTap: function (e) {
if (!$scope.data.expensetype) {
e.preventDefault();
} else {
addExpenseCategory();
return $scope.data.expensetype;
}
}
},
]
});
myPopup.then(function (res) {
$log.log('Tapped!', res);
});
}