Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ng repeat&;javascript对象_Javascript_Angularjs - Fatal编程技术网

ng repeat&;javascript对象

ng repeat&;javascript对象,javascript,angularjs,Javascript,Angularjs,这是我的目标: $scope.tickets = [{ title: "Bug 1", number: 1, desc: 'Description #1', assigned: [{ name: "Someone", group: "Development" }] }, { title: "Bug 2",

这是我的目标:

     $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"
         }]
     }];
  • 我正在做一个表格来显示所有的内容,在里面我正在做一个hg重复,但我不知道如何访问分配的列表下的名称和组信息

    <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>  
    
  • 而且不起作用

  • 正如你所看到的,我正在将对象发送到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>
    

    似乎可以吗?

    您定义的赋值为对象数组

    assigned: [{
                 name: "Someone3",
                 group: "Support"
             }]
    
    将其定义为对象(不带[])或将其作为数组访问

    assigned: {
                 name: "Someone3",
                 group: "Support"
             }
    
    如果确实需要将其作为数组,请使用嵌套的ng repeat,如下所示:

    <td><div ng-repeat="assigned in ticket.assigned">{{assigned.group}} / {{assigned.name}}</div></td>
    
    {{assigned.group}/{{assigned.name}
    
    ng应用程序和ng控制器属性在哪里?另外,请上传js文件中的角度声明。ng-app在我的html标记中。我的控制器在div中。你将如何按组进行过滤?ng repeat=“assigned in ticket.assigned | filter:{group:'Support'}”我昨天做了这件事,然后回答了你的问题,我丢弃了一个plunker,它正在工作。再试一次。如果你做不到的话,我今晚就给你一顿痛快。
    assigned: {
                 name: "Someone3",
                 group: "Support"
             }
    
    <td><div ng-repeat="assigned in ticket.assigned">{{assigned.group}} / {{assigned.name}}</div></td>