2016-06-28 63 views
-2

多發性複選框值的值來獲得:如何用我的html頁面angularjs

<body ng-app> 
    <div class="wrapper wrapper-content" ng-controller="InboxMailCtrl"> 
     <tr ng-repeat="CU in InboxList"> 
      <td class="check-mail"> 
       <input type="checkbox" ng-model="CU.Selected" value="{{CU.InboxMailID}}" class="i-checks" > 
      </td> 
      <td class="text-right mail-date">{{CU.time}}</td> 
     </tr> 
     <button ng-click="Delete()"></button> 
    </div> 
</body> 

,並在我的js文件:

var InboxMailCtrl = function ($scope, $http) { 

    BindInboxList(); 
    function BindInboxList() { 

     $http({ 
      url: "MailRoute/getDataForMailInbox", 
      dataType: 'json', 
      method: 'POST', 
      data: obj, 
      headers: { 
       "Content-Type": "application/json" 
      } 
     }).success(function (response) { 
      debugger; 
      $scope.InboxList = response; 

     }).error(function (error) { 
      alert(error); 
     }); 
    } 


$scope.Delete = function() { 
     debugger 
     $scope.MailNameArray = []; 
     angular.forEach($scope.InboxList, function (CU) { 
      if (!!CU.selected) $scope.MailNameArray .push(CU.InboxMailID); 
     }) 
    } 

$scope.Delete被選中ckeckbox項目價值MailNameArray,但我不能夠將選中的複選框數據推送到這個數組中。

出了什麼問題?

我使用的是webAPI控制器,而getDataForMailInbox是api控制器中的一個函數。

+0

,你可以把它放在一個小提琴或其他事端,所以我們可以看到到底發生了什麼,應該發生.... – MrBuggy

回答

0
ng-model="CU.Selected" 
      ^

if (!!CU.selected) 
     ^

不同

+0

現在我有編輯完整的html代碼here.i已將(!! cu.selected)更改爲CU.selected,但無法正常工作 –

+0

呃..您需要修復'ng-model'中的大寫字母S' – Icycool

+0

非常感謝.100%正確的解決方案。你可以告訴我如何將MailNameArray數組發送到webapi控制器ASE? –

相關問題