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