0
Keeping in mind that I have an ng-repeat, how do I pick up only the items I marked in the checkbox?
0
Keeping in mind that I have an ng-repeat, how do I pick up only the items I marked in the checkbox?
0
Following example, see if it meets you.
function MyCtrl($scope) {
$scope.itens = [
{id: 1,name: "nome 1"},
{id: 2,name: "nome 2"},
{id: 3,name: "nome 3"}
];
$scope.marcados = function() {
var checkedItems = [];
angular.forEach($scope.itens, function(item, arrayIndex) {
if (item.id === true) {
checkedItems.push(item)
}
})
return checkedItems
}
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
</script>
<div ng-app="" ng-controller="MyCtrl">
<ul>
<li ng-repeat="item in itens">
<input type="checkbox" ng-model="item.id">{{item.name}}
</li>
</ul>
{{itens}}
<br><br>
marcados: {{marcados()}}
</div>
Browser other questions tagged php javascript angularjs html5 dom
You are not signed in. Login or sign up in order to post.
Could you enter what you were trying to please? http://answall.com/help/mcve
– BrTkCa