Service Portal - Issue with the selectboxes and the ng-repeat is not working

Revathi Kotha
Tera Contributor

 

Hello All,
When one select box value is selected, the other select box values in the table are changed. Is there anything wrong with the code?

 

HTML
 
 
<td><select id="manager_action" ng-model="c.data.manager_action" class="form-control" ng-change="c.changeAction({{x.employee_number}})" ng-options="y.name for y in data.actions" ng-required="true"> </select> </td>
 
Server Script: data.actions=[{ name:'Keep', value:'1' }, { name:'Remove', value:'2' }]

 

1 ACCEPTED SOLUTION

I'm assuming you want to prevent submission functionality if the required fields are not filled?

 

You need to add a name attribute to the form

<form name="formName">

 

Then check if the form is valid (all required fields are met) when the submit button is clicked

 <button class="test" class="btn btn-primary btn-block" ng-click="c.uiAction('remove')" ng-disabled="formName.$invalid">Keep All</button>

 

View solution in original post

23 REPLIES 23

You are right.I missed that :(. I appreciate all your help, and thanks for routing me in the right direction 🙂

 

These tips will help me build a widget without error in the future.

 

Sorry for asking too many questions. One last question. ng-required="true" is not working in the HTML part. I have already shared the code in the HTML part above. If it's not clear, I can share it again. Please let me know

I'm assuming you want to prevent submission functionality if the required fields are not filled?

 

You need to add a name attribute to the form

<form name="formName">

 

Then check if the form is valid (all required fields are met) when the submit button is clicked

 <button class="test" class="btn btn-primary btn-block" ng-click="c.uiAction('remove')" ng-disabled="formName.$invalid">Keep All</button>

 

Thank you so much @TFischer 

Revathi Kotha
Tera Contributor

@TFischer  I for got to ask you about this.

 

"Here we are binding a unique value for all inputs per row. This will likely cause a new console error such as "c.data.manager_action is undefined" but we can fix that by mapping a manager_action key to your data object on the server script. I can help you if you see an error and share your server script."

 

How do you get the value of each row in the client script? It helps to update all the values to 'Keep' when the 'Keep All ' option is selected.

It depends on the data structure of your array in your ng-repeat. You will most likely want to store the value of the action as a key on every individual object in that array. Then you can update all object when "Keep All" is selected.