0
我需要在點擊一個表中的行獲得的價值和彈出式窗口中顯示它獲取價值並把它傳遞給彈出
HTML:
<md-data-table-container>
<table md-data-table class="md-primary" md-progress="deferred">
<thead md-order="query.order" md-trigger="onorderchange">
<tr>
<th name="Task To Be Done"></th>
<th name="Office"></th>
<th name="Due Date"></th>
</tr>
</thead>
<tbody ng-click="showAlert($event)">
<tr ng-repeat="dessert in desserts.data" ng-click="showAlert($index)" flex-sm="100" flex-md="100" flex-gt-md="auto">
<td>{{dessert.task}}</td>
<td></td>
<td>{{dessert.due_on}}</td>
</tr>
</tbody>
</table>
</md-data-table-container>
JS:
$scope.desserts = {
"count": 6,
"data": [{
"task": "Frozen yogurt",
"type": "Ice cream"
}, {
"task": "Ice cream sandwich",
"type": "Ice cream"
}, {
"task": "Eclair",
"type": "Pastry"
}, {
"task": "Cupcake",
"type": "Pastry"
}, {
"task": "Jelly bean",
"type": "Candy"
}, {
"task": "Lollipop",
"type": "Candy"
}, {
"task": "Honeycomb",
"type": "Other"
}]
};
$scope.showAlert = function (index) {
$scope.obj = $scope.desserts.data[2];
$scope.task = $scope.obj.task;
alert($scope.task);
console.log($scope.task);
};
問題在我的代碼是,我可以得到我指定「。數據[2]」的數組上的值。實際上,當我點擊表格中的一行時,我需要顯示該值以彈出「sweetAlert」。是否有任何解決方案
這不是很清楚。你有一個沙漠陣列,但沒有顯示它,你有一個點擊調用$索引,但沒有重複圍繞它。甜蜜的警報來自哪裏?你從不打電話或使用它?你怎麼認爲有人可能會告訴你什麼是錯的。用你的代碼創建一個plunkr或jsfiddle。 – Shaun
檢查我的更新後的代碼 –
添加了答案。我不知道「sweetAlert」是什麼意思。 – Shaun