如何在使用Angularjs的条件下使用ng-show和ng-hide?

时间:2017-01-06 05:54:35

标签: html angularjs

我正在研究angularjs。我在我的html表中使用ng-show和ng-hide。我需要在if条件中显示值以同样的方式显示我的融合图中的相应值。

让我告诉你默认情况下我的图表计数的组合。enter image description here

这是我的htmlscript

的index.html

<tbody>
    <tr ng-hide="content == 'other'" ng-repeat='p in view_data'>
       <td><span>{{p.product}}</span></td>
       <td><span>{{p.bucket}}</span></td>
       <td><span>{{p.countOfAllocatedAccount}}</span></td>
       <td><span>{{p.countOfCollectedAccount}}</span></td>
       <td><span>{{p.countOfPendingCollectionOfAccounts}}</span></td>
   </tr>
   <tr ng-show="content == 'other'" ng-repeat='p in view_data'>
       <td><span>{{p.product}}</span></td>
       <td><span>{{p.bucket}}</span></td>
       <td><span>{{p.sumOfAllocatedAccount}}</span></td>
       <td><span>{{p.sumOfCollectedAccount}}</span></td>
       <td><span>{{p.sumOfPendingAllocatedAndCollectedAmounts}}</span></td>
   </tr>
 </tbody>

的script.js

如果ng-hide="content == 'other'"显示此值

if(data[p].product==products[j])
     {
     var productWiseAllocation = {};
     productWiseAllocation.name=data[p].product;
     productWiseAllocation.series= data[p].bucket;
      productWiseAllocation.amount= data[p].countOfAllocatedAccount;
      //productWiseAllocation.amount= data[p].sumOfAllocatedAccount;
      productWiseAllocationarr.push( productWiseAllocation);
      var productWiseCollection ={};
      productWiseCollection.name=data[p].product;
       productWiseCollection.series=data[p].bucket;
        productWiseCollection.amount=data[p].countOfCollectedAccount;
        //productWiseCollection.amount=data[p].sumOfCollectedAccount;
        productWiseCollectionarr.push( productWiseCollection);
     }

对于金额的组合,即enter image description here

如果ng-show="content == 'other'"我需要在融合图表中显示这些值。

else{
      var productWiseAllocation = {};
     productWiseAllocation.name=data[p].product;
     productWiseAllocation.series= data[p].bucket;
      productWiseAllocation.amount= data[p].sumOfAllocatedAccount;
      //productWiseAllocation.amount= data[p].sumOfAllocatedAccount;
      productWiseAllocationarr.push( productWiseAllocation);
      var productWiseCollection ={};
      productWiseCollection.name=data[p].product;
       productWiseCollection.series=data[p].bucket;
        productWiseCollection.amount=data[p].sumOfCollectedAccount;
        //productWiseCollection.amount=data[p].sumOfCollectedAccount;
        productWiseCollectionarr.push( productWiseCollection);

     }

任何人都可以帮助我吗?

0 个答案:

没有答案