Reputation: 77
here is my object:
$scope.tickets = [{
title: "Bug 1",
number: 1,
desc: 'Description #1',
assigned: [{
name: "Someone",
group: "Development"
}]
},
{
title: "Bug 2",
number: 2,
desc: 'Description #1',
assigned: [{
name: "someone2",
group: "Development"
}]
},
{
title: 'Random unknown issue',
number: 3,
desc: 'Description #3',
assigned: [{
name: "Someone3",
group: "Support"
}]
}];
I am doing a table to display all the content and inside im doing an hg-repeat but i do not know how to access the name and group info under the assigned
<p class="lead">Development:</p>
<div class="table-responsive">
<table class="table table-striped table-condensed">
<thead>
<tr>
<!-- <th>index</th> -->
<th>#</th>
<th>Title</th>
<th>Description</th>
<th>Group/Assigned</th>
<th>Advanced</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="ticket in tickets">
<td>{{ticket.number}}</td>
<td>{{ticket.title}}</td>
<td>{{ticket.desc}}</td>
<td>{{ticket.assigned.group}} / {{ticket.assigned.name}}</td>
<td>
<button class="btn btn-primary" ng-click="sendToSupport(ticket)">Send to Support</button>
</td>
</tr>
</tbody>
</table>
</div>
I have tried filtering the ng-repeat by
| filter: {group: 'Support'}
and does not work
aslo as you can see im sending the object into an ng-click
<tr ng-repeat="ticket in tickets">
<td>{{ticket.number}}</td>
<td>{{ticket.title}}</td>
<td>{{ticket.desc}}</td>
<td>{{ticket.assigned.group}} / {{ticket.assigned.name}}</td>
<td>
<button class="btn btn-primary" ng-click="sendToSupport(ticket)">Send to Support</button>
</td>
what i am doing is this
$scope.sendToDev = function(ticket){
this.ticket.assigned.group = "Support"
}
seems ok?
Upvotes: 0
Views: 235
Reputation: 945
You defined assigned as an array of object
assigned: [{
name: "Someone3",
group: "Support"
}]
Define it as a object (without the []) or access it as an array.
assigned: {
name: "Someone3",
group: "Support"
}
If you really need it to be an array, use a nested ng-repeat like this :
<td><div ng-repeat="assigned in ticket.assigned">{{assigned.group}} / {{assigned.name}}</div></td>
Upvotes: 2