I have a table cell set up to send back a value when its clicked. Ideally i would like to get it to send back two values in the payload.
<td ng-click="send({payload: device.deviceName, level:device.object.alertLevel})">{{device.object.alertLevel}}</td>
It seems I can send one or the other but not both. Is there a way to do this?
You can do it (I'll demonstrate below) but whats wrong with simple adding more properties to the payload?
Alt solution (put this in your ui_template)...
<table>
<tr>
<td>
<button ng-click="send2('hello', 'goodbye')">click me</button>
</td>
</tr>
</table>
<script>
var $scope = this.scope;
this.scope.send2 = function(payload1, payload2) {
$scope.send({payload:payload1});
$scope.send({payload:payload2});
}
</script>
Assumption...
you are using ui_template to make your table (you didn't say)
2 Likes
hi @Steve-Mcl
yes I am using ui_template to create the table, sorry for not mentioning that.
The table is being created by ng-repeat so I would need to set ng-click="send2('hello', 'goodbye')" using "device.deviceName" and "device.object.alertLevel"
I think i have found the way to pass this information
<td ng-click="send({payload: {deviceName: device.deviceName, aLvl: device.object.alertLevel}})">{{device.object.alertLevel}}</td>
adding the ineer curly brackets seems to allow it to work.
<td><button ng-click="send({payload: {deviceName: device.deviceName, aLvl: device.object.alertLevel}})">click me</button></td>
Using a button inside the table seems to work this way as well.
Thank you for your help The table looks a lot nicer with buttons in it rather than just having a cell to click.
system
Closed
28 August 2020 23:37
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.