2017-01-05 58 views
1

我試圖顯示一個複選框,下拉框和使用angularjs在圖像中顯示的文本框。但我無法做到,現在我顯示一切在另一個之下。另外,如何爲表格中的不同文本框獲取不同的值,以便表格中的每一行的時間計算不同。使用複選框,下拉框和文本框

enter image description here

控制器:

mainApp.controller('settings-controller', function ($scope) { 
    $scope.fields = [{ id: 1, name: 'Sunday' }, 
    { id: 2, name: 'Monday' }, 
    { id: 3, name: 'Tuesday' }, 
    { id: 4, name: 'Wednesday' }, 
    { id: 5, name: 'Thursday' }, 
    { id: 5, name: 'Friday' }, 
    { id: 5, name: 'Sunday' }]; 

HTML:

<ion-checkbox ng-repeat="field in fields" ng-model="field.checked" ng-checked="field.checked"> 
      {{field.name}} 
     </ion-checkbox> 
<input type="text" ng-model="medicinetime"> 
<select ng-model="time" ng-options="time for time in hours" 
<option value="">Select</option> 
</select> 

回答

2

這只是一個table tr td唯一格式。你需要trtd標籤的類似如下格式添加ng-repeat(請提供他們所需要的正確的數組對象名稱。)

<table> 
<tr ng-repeat="field in fields"> 
<td> 
<ion-checkbox ng-repeat="field in fields" ng-model="field.checked" ng-checked="field.checked"> 
      {{field.checked}} 
     </ion-checkbox></td> 
<td> 
<input type="text" ng-model="field.name"></td> 
<td> 
<select ng-model="field.time" ng-options="time for time in hours" 
<option value="">Select</option> 
</select></td></tr> 
</table> 
+0

整個天重複7次(即週一週日.... ,星期一...星期日,星期一....星期日) – Rudhra

+0

是的。它是按行進行編譯的。這就是爲什麼我提到你應該初始化你想要的數組對象 –