I am trying to pass a variable from a table to Form-Modal, hence need a little guidance on snippet. Please refer to the HTLML section.
I need to pass {{rec.sys_id}}
into a method as a parameter, which is inside this form-modal:
"myController.displayUserRecord(<rec.sys_id>)"
Please let me know about the approach.
Thank you.
<table>
<tr ng-repeat="rec in myController.userRecord">
<td><a ng-href="" target="" data-toggle="modal" data-target="#formUserRecord">Click Here</a></td>
<td>{{rec.sys_id}}</td>
</tr>
</table>
<div class="modal fade" id="formUserRecord" tabindex="-1" role="dialog">
<p>Check your Workday Record:</p>
<button type="button" ng-click="myController.displayUserRecord(<rec.sys_id>)">Click here </button>
</div>
2
Answers
please try this
To pass the
rec.sys_id
value from the table to thedisplayUserRecord
method in the form modal, you can make use of AngularJS data binding. Modify your HTML as follows:In your controller (assuming it’s named
myController
), you need to define thesetSelectedSysId
method to set the selectedsys_id
. You can then use this value in thedisplayUserRecord
method.This way, when a user clicks on "Click Here" in the table, the
setSelectedSysId
method will be called, setting theselectedSysId
variable. Later, when the user clicks "Click here" in the modal, thedisplayUserRecord
method will be called, and you can access the selectedsys_id
from theselectedSysId
variable in the controller.