0

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"
         }]
     }];
  1. 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>  
    
  2. I have tried filtering the ng-repeat by

     | filter: {group: 'Support'}
    

and does not work

  1. 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?

2
  • Where is the ng-app and ng-controller attrs? also, please upload the angular declarations in your js file. Commented Aug 25, 2013 at 19:45
  • 1
    ng-app is inside my html tag <html ng-app="app"> my controller is in a div <!--ticketsController--> <div class="container" ng-controller="ticketsCtrl"> Commented Aug 25, 2013 at 20:07

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

3 Comments

how would you filter by the group?
ng-repeat="assigned in ticket.assigned | filter: {group: 'Support'}"
I did it yesterday before answering you on a plunker that I did discard and it was working. Try again. If you are not able to do it, I will give you a plunker tonight.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.