I have Popover ionic with some list (-Bills, -Education, -Medical, -Other), and all list have ng-click="CloseInController()".
but i want, only list "Other" to add ng-click="showListIns()", so if i click "Other" any Popup to display it.
This my sample code app.js for Popover :
.controller('PopOver', function($scope, $ionicPlatform, $ionicPopover, Category, Expense) {
Category.all('D').then(function(res) {
console.log(res);
console.log("inilah " + res.length);
if (res.length > 0) {
$scope.ListCategory = res;
} else {
var cat = {};
cat.Type = 'D';
cat.Name = 'Bills';
Category.add(cat);
cat.Name = 'Education';
Category.add(cat);
cat.Name = 'Entertainment';
Category.add(cat);
cat.Name = 'Food and Drink';
Category.add(cat);
cat.Name = 'Medical';
Category.add(cat);
cat.Name = 'Shopping';
Category.add(cat);
cat.Name = 'Travel';
Category.add(cat);
cat.Name = 'Other';
Category.add(cat).then(function(res) {
window.location.reload();
});
}
})
$scope.showPopover = function($event, index, ExpenseId)
{
//console.log(ExpenseId);
$scope.index = index;
$scope.ItemId = ExpenseId;
/* $scope.index = index; */
$scope.popover.show($event);
}
$scope.closeInController = function(selectedItem, ExpenseId) {
Expense.updateCategory(selectedItem, ExpenseId);
$scope.popover.hide();
};
});
})
and this my code for Popover :
<ion-popover-view>
<ion-content>
<div id="popup">
<ion-scroll style="height: 150px;">
<label ng-repeat="item in ListCategory" for="{{item.Name}}">
<input type="radio"
ng-model="my.favorite"
ng-value="item.Name"
ng-click="closeInController(item.CategoryId, ItemId)"
id="{{item.CategoryId}}"
name="category">
{{item.Name}}
<br>
</label>
</ion-scroll>
</div>
</ion-content>
</ion-popover-view>
Anyone can help me?
Thanks in advance
just write a wrapper function for your ng-click
and pass parameter to choose which function should be called.
HTML:
ng-click="wrapperFunc('showListIns', param1, param2)"
CONTROLLER
$scope.wrapperFunc = function(functionName){
if(functionName === 'showListIns') showListIns(param1, param2);
else if (functionName === 'closeInController') closeInController(param1, param2);
}