Javascript 使用AngularJS中的ng show在表中显示表

Javascript 使用AngularJS中的ng show在表中显示表,javascript,angularjs,angular-material,Javascript,Angularjs,Angular Material,我有一个表,在单击一行之后,我希望在单击该行之后显示新的子表。我在单击行时调用新的api,所以我必须在单击行之后在新表中显示它。查看快照 单击第一行后,新表显示为1,ABC_1,DEF 下面是模板的代码 <table md-table class="md-primary md-data-table"> <thead md-head md-order="vm.query.order"> <tr md-row> <th md-col

我有一个表,在单击一行之后,我希望在单击该行之后显示新的子表。我在单击行时调用新的api,所以我必须在单击行之后在新表中显示它。查看快照

单击第一行后,新表显示为1,ABC_1,DEF 下面是模板的代码

<table md-table class="md-primary md-data-table">
   <thead md-head md-order="vm.query.order">
   <tr md-row>
       <th md-column><span>S. No.</span></th>
       <th md-column><span>Project Name</span></th>
       <th md-column><span>Deadline</span></th>
   </tr>
   </thead>
   <tbody md-body>
   <tr md-row ng-click="vm.ShowDetailed($index)" ng-repeat="project in vm.projects | limitTo : vm.query.limit : (vm.query.page-1)*vm.query.limit">
      <td md-cell>{{($index+1)+(vm.query.page-1)*vm.query.limit}}</td>
      <td md-cell>{{project.fields.project_name}}</td>
      <td md-cell>{{project.fields.end_date}}</td>
      <table md-table ng-show="vm.detailedShow[$index]"> 
         <thead md-head>
            <tr md-row>
            <th md-column><span>Project Name</span></th>
            <th md-column><span>District</span></th>
            <th md-column><span>City</span></th>
            </tr>
         </thead>
         <tbody md-body>
            <tr md-row ng-repeat="site in sites">
                <td md-cell>{{site.projectName}}</td>
                <td md-cell>{{site.district}}</td>
                <td md-cell>{{site.city}}</td>
            </tr>
         </tbody md-body>
      </table>
     </tr>
   </tbody>
 </table>

vm.detailedShow[$index]的值在单击时变为true/false,但我仍然无法显示该表。

首先,您不能像插入
一样插入
。但是您可以将表插入
标记中

试试下面这个

<table md-table class="md-primary md-data-table">
   <thead md-head md-order="vm.query.order">
   <tr md-row>
       <th md-column><span>S. No.</span></th>
       <th md-column><span>Project Name</span></th>
       <th md-column><span>Deadline</span></th>
   </tr>
   </thead>
   <tbody md-body>
   <tr md-row ng-click="vm.ShowDetailed($index)" ng-repeat-start="project in vm.projects | limitTo : vm.query.limit : (vm.query.page-1)*vm.query.limit">
      <td md-cell>{{($index+1)+(vm.query.page-1)*vm.query.limit}}</td>
      <td md-cell>{{project.fields.project_name}}</td>
      <td md-cell>{{project.fields.end_date}}</td>
   </tr>
   <tr ng-show="vm.detailedShow[$index]" ng-repeat-end>
      <td> </td>
      <td colspan="2"> 
           <table md-table ng-show="vm.detailedShow[$index]"> 
         <thead md-head>
            <tr md-row>
            <th md-column><span>Project Name</span></th>
            <th md-column><span>District</span></th>
            <th md-column><span>City</span></th>
            </tr>
         </thead>
         <tbody md-body>
            <tr md-row ng-repeat="site in sites">
                <td md-cell>{{site.projectName}}</td>
                <td md-cell>{{site.district}}</td>
                <td md-cell>{{site.city}}</td>
            </tr>
         </tbody md-body>
      </table>
      </td>
   </tr>
   </tbody>
 </table>

美国号。
项目名称
截止日期
{{($index+1)+(vm.query.page-1)*vm.query.limit}
{{project.fields.project_name}
{{project.fields.end_date}
项目名称
地区
城市
{{site.projectName}
{{site.district}}
{{site.city}

首先,您不能像插入
那样插入
。但是您可以将表插入
标记中

试试下面这个

<table md-table class="md-primary md-data-table">
   <thead md-head md-order="vm.query.order">
   <tr md-row>
       <th md-column><span>S. No.</span></th>
       <th md-column><span>Project Name</span></th>
       <th md-column><span>Deadline</span></th>
   </tr>
   </thead>
   <tbody md-body>
   <tr md-row ng-click="vm.ShowDetailed($index)" ng-repeat-start="project in vm.projects | limitTo : vm.query.limit : (vm.query.page-1)*vm.query.limit">
      <td md-cell>{{($index+1)+(vm.query.page-1)*vm.query.limit}}</td>
      <td md-cell>{{project.fields.project_name}}</td>
      <td md-cell>{{project.fields.end_date}}</td>
   </tr>
   <tr ng-show="vm.detailedShow[$index]" ng-repeat-end>
      <td> </td>
      <td colspan="2"> 
           <table md-table ng-show="vm.detailedShow[$index]"> 
         <thead md-head>
            <tr md-row>
            <th md-column><span>Project Name</span></th>
            <th md-column><span>District</span></th>
            <th md-column><span>City</span></th>
            </tr>
         </thead>
         <tbody md-body>
            <tr md-row ng-repeat="site in sites">
                <td md-cell>{{site.projectName}}</td>
                <td md-cell>{{site.district}}</td>
                <td md-cell>{{site.city}}</td>
            </tr>
         </tbody md-body>
      </table>
      </td>
   </tr>
   </tbody>
 </table>

美国号。
项目名称
截止日期
{{($index+1)+(vm.query.page-1)*vm.query.limit}
{{project.fields.project_name}
{{project.fields.end_date}
项目名称
地区
城市
{{site.projectName}
{{site.district}}
{{site.city}

该走了。。谢谢,我错过了ng重复开始和ng重复结束。加油。。谢谢,我错过了ng重复开始和ng重复结束。