Reputation: 291
I am using grails select dropdown element. I need to set default value for select2 dropdown options while click edit option in a form using angularjs..when i click edit button, then i have fetch related data for that form and update to form fields value as json object..Now normal text fields has been updated successfully.but select-2 dropdown fields doesn't updated to current value as selected.What's wrong with my code..here i have set common name for form model and object key like object key name and ng-model name are same for all datas..
Thanks advanced..
My Object for update to form fields:
Object {id: 3, name: "uday", code: "1", moveTaskType: "SPOT", priority: 1…}
My Form select2 Code:
<g:select id="moveTaskType" name="moveTaskType" from="${com.aa.fsight.MoveTaskRuleDef.MoveTaskType.class.getEnumConstants().collect{[name:it.name(), type: it.type]}}" optionKey="name" optionValue="type" class="select2 multiSelect" noSelection="['':'None']" ng-model="taskCreateForm.moveTaskType" />
My Controller code for data updation:
$scope.taskCreateForm=data;
Upvotes: 0
Views: 831
Reputation: 208
Why you don't use the select of angularjs ? You can bind the property directly with your tabs and choose your default selection.
Upvotes: 0