Shanmugam Rajagopal
asked on
Select 1st Row radio button by default and fire ng-click event in angular
I am populating a table by adding first column as radio button. Want to select first row radio button as default and fire the radio button event ng-click.
Thanks for your help in advance.
<div class="col-5-md col-lg-8">
<div class="well well-sm">
<table id="eventsTable" st-safe-src="vm.AllEmployees" st-table="displayCollection" class="table table-striped">
<thead>
<tr>
<th> </th>
<th st-sort="EMPLOYEE_ID">EMPLOYEE ID</th>
<th st-sort="EMPLOYEE_NAME">EMPLOYEE NAME</th>
</tr>
</thead>
<tbody>
<tr st-select-row="row" ng-repeat="row in displayCollection">
<td><input type="radio" value="false" name="eventsRadio" ng-click="vm.onEventSelection(row)" /></td>
<td>{{::row.EMPLOYEE_ID}}</td>
<td>{{::row.EMPLOYEE_NAME}}</td>
</tr>
</tbody>
</table>
</div>
</div>
Thanks for your help in advance.
ASKER
Julian,
I had ng-modal for radio but I removed because my first goal was to check the first row by default and display its associated row values to a label.
If you could explain me how to fire ng-click from controller that would be great. I am very new to angular and in learning process.
Thanks for your help in advance
I had ng-modal for radio but I removed because my first goal was to check the first row by default and display its associated row values to a label.
If you could explain me how to fire ng-click from controller that would be great. I am very new to angular and in learning process.
Thanks for your help in advance
Angular requires a bit of a shift in thinking. Because of the two way binding your application changes from one that is about manipulating the DOM to one that is based on state. You link view elements to the model such that when the model changes your view changes automatically.
When you assign your radio button to the model with ng-model you now link the state of the radio button to the model and vice versa.
When you say you want to fire an ng-click - why - what is it that click function does,
When you assign your radio button to the model with ng-model you now link the state of the radio button to the model and vice versa.
When you say you want to fire an ng-click - why - what is it that click function does,
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
The bit about firing the ng-click - why not just invoke that function from the controller when the page loads?