<button class="btn btn-conf-t btn-deletar" ng-click="deleteCategory(cat.id)"><i class="fa fa-trash"></i></button>
Here I just pass one parameter, is it possible to pass ng-click="deleteCategory(cat.id, cat.nome)"
?
<button class="btn btn-conf-t btn-deletar" ng-click="deleteCategory(cat.id)"><i class="fa fa-trash"></i></button>
Here I just pass one parameter, is it possible to pass ng-click="deleteCategory(cat.id, cat.nome)"
?
It's just separated with a comma like this:
deleteCategory(cat.id, cat.name)
Getting this way:
<button class="btn btn-conf-t btn-deletar" ng-click="deleteCategory(cat.id, cat.name)"><i class="fa fa-trash"></i></button>
Remembering that your deleteCategory
function must be changed to get both values.
If you want to perform two functions, you only have to call both of them within deleteCategory
.
See a small example:
angular.module('myApp', [])
.controller('myCtrl', ['$scope', function($scope) {
$scope.count = 0;
$scope.somar = function(val, val2) {
$scope.count = val + val2;
};
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><bodyng-app="myApp">
<div ng-controller="myCtrl">
<button ng-click="somar(2, 5)">OK</button>
<p>Resultado: {{count}} </p>
</div>
</body>
... is it possible to pass ng-click="deleteCategory (cat.id, cat.name)"?
Yes, it is possible. However, your event model might be even more resilient if you pass the object reference :
ng-click="deleteCategory(cat)"
Within your controller you can then read the properties of the referenced object:
$scope.deleteCategory = function (cat) {
console.log(cat.id, cat.nome);
}