I receive this json from a service after client call.
JSON
[ {
"Accreditment" : {
"Id" : "1",
"Creator" : "John Smith",
"IdCreator" : "1",
"CreationDate" : "2014-07-01T18:13:51+02:00",
"CostCenter" : [ "5411-Channel1", "5412-Channel2" ],
"Destination" : [ "Playout Channel1", "Playout Channel2" ],
"IdUserEnabled" : [ "1", "2" ],
"WorkOrderType" : [ "New Asset", "Subtitling" ],
"StartDate" : "2013-05-04T18:13:51+02:00",
"EndDate" : "2014-10-04T18:13:51+02:00",
"Status" : "enabled"
}
} ]
I want get select option value in my controller
THIS IS MY LIST OPTION
"CostCenter" : [ "5411-Channel1", "5412-Channel2" ],
and this is my html with select HTML
<form role="form">
<div class="form-group row more-margin-top" ng-repeat="work in WorkOrder">
<div class="col-xs-12">
<label>Selezione centro di costo</label> <select class="form-control" ng-change="selectAction()">
<option ng-model="myOption" ng-repeat="cost in work.Accreditment.CostCenter" value="{{cost}}">
{{cost}}
</option>
</select>
</div><!-- /.col-xs-3 -->
</div>
</form>
CONTROLLER
mwm3.controller('CreateWorkOrderCtrl',function($scope){
$scope.selectAction=function(){
//HERE I WANT MY SELECT OPTION SELECTED
};
});
HOW CAN DO IT? thanks in advance
UPDATE---------------
HTML
<div class="form-group" ng-repeat="work in WorkOrder">
<div class="row more-margin-top">
<div class="col-xs-12">
<label>Selezione centro di costo</label>
<select class="form-control" ng-model="myOption" ng-change="selectAction()">
<option ng-repeat="cost in work.Accreditment.CostCenter" value="{{cost}}">{{cost}}</option>
</select>
</div><!-- /.col-xs-3 -->
</div>
</div>
but i receive undefined in log in my controller
ng-model
to theselect
, not theoption
and use$scope.myOption
. – Sergiu Paraschiv Jul 4 at 13:09