2015-04-17 59 views
0

已經開始在mvc中使用Angular.js進行編碼,並且我遇到了問題如何獲取表格中的數據以更改按鈕單擊提醒到客戶信息可以說我點擊客戶時顯示的信息頁面中顯示的數據,並且當我點擊提醒時我想要提醒表格中的數據。我還有一個問題,即搜索計數數據庫中的數字,但不是在過濾表格後顯示的數字扔了search.Any幫助將不勝感激thanks.Also如果任何人知道如何做簡單的分頁,這將是完美的感謝。Angular.js更改按鈕點擊表格數據

<script> 
     var MyApp = angular.module('MyApp', []); 
     MyApp.controller('MyAppCtrl', function ($scope) { 
      $scope.Info = [ 
       { "date":"23/09/2014","name": "john", "detail": "sssss" }, 
       { "date": "27/09/2014", "name": "mary", "detail": "gggggg" } 


      ]; 
$scope.remind = [ 
        { "date":"23/09/2014", "detail": "milk" }, 
        { "date": "27/09/2014","detail": "bread" } 


       ]; 
     $scope.sortField = 'name';//starting sort 
     $scope.reverse = true; 
     }); 


    </script> 
    <div class="container" ng-app="MyApp"> 
     <div class="row" style="padding-top: 60px"> 
      <div class="panel panel-warning"> 
       <div class="panel-heading">Home 

       </div> 
       <div class="panel-body"> 

        @* left *@ 
        <div class="col-md-4"> 
         <div class=""> 

          <div class="butLay"> 
           @Html.ActionLink("Reminders", "Reminders", null, new { @class = "btn btn-warning btn-md" }) 
          </div> 
         </div> 
         <div class="butLay"> 



          @Html.ActionLink("Expected customer", "Expectedcustomer", null, new { @class = "btn btn-info btn-md" }) 
         </div> 

        </div> 


        @* Right side*@ 
        <div class="pr col-md-6" ng-controller="MyAppCtrl"> 
         Search:<input ng-model="query" type="text" /> 
         <span class="label label-info">{{Info.length}} </span> 
         <table class="table table-striped table-hover "> 
          <thead> 
           <tr> 
            <th><a href="" ng-click="sortField = 'date'; reverse = !reverse">Date</a></th> 
            <th><a href="" ng-click="sortField = 'name'; reverse = !reverse">Name</a></th> 
            <th><a href="" ng-click="sortField = 'detail'; reverse = !reverse">detail</a></th> 
           </tr> 
          </thead> 
          <tbody> 


           <tr ng-repeat="custom in Info| filter:query | orderBy:sortField:reverse"> 
            <td>{{custom.date}}</td> 
            <td>{{custom.name}}</td> 
            <td>{{custom.detail}}</td>    
           </tr>     
          </tbody> 
         </table> 
         @*<ul class="pagination pagination-sm"> 
          <li class="disabled"><a href="#">«</a></li> 
          <li><a href="#">1</a></li> 
          <li><a href="#">2</a></li> 
          <li><a href="#">3</a></li> 
          <li><a href="#">4</a></li> 
          <li><a href="#">5</a></li> 
          <li><a href="#">»</a></li> 
         @*</ul>*@ 


        </div> 

       </div> 
       <table class="table table-condensed table-hover table-striped"></table> 
      </div> 
      @* of panel *@ 
     </div> 
     @*of row*@ 
    </div> 
    @* of container *@ 

回答

0

可以使2個表和一個具有

ng-if="variable==false"; 

對方已經

ng-if="variable==true"; 

則U做

ng-click="myfunction(variable)" 

,並在控制器u有一個按鈕

$scope.myfunction = function(variable){ 

    if(variable == true){ 
     variable = false; 
    }else{ 
     variable = true; 
    } 
} 

所以當u點擊變量被設置爲真或假,右邊的內容顯示

要設置哪些表應當defaul

ng-init="variable==true" 

例如

希望這出幫助

+0

所以我正確地說$ scope.myfunction = function(提醒,招生){ if(Reminder == true){ Admissions = false;其他{ Admissions = true; } } and