Texs

by Kunal Paul

HTML

<div ng-app="myApp" ng-controller="myCtrl">
  <select ng-model="modelValue" ng-options="getId(option.id) as option.name for option in myarray"> 
  
  </select>
</div>

JavaScript

var app = angular.module('myApp', []);
app.controller('myCtrl',function($scope,$window){
		$scope.modelValue=1;
    $scope.myarray=[ {id:1, name:'A'} , {id:2, name:'B'} ];
    
    $scope.getId = function(id)
    {
    	if(typeof $scope.modelValue == "string")
      	return String(id);
       else if(typeof $scope.modelValue == "number")
       	return parseInt(id);
    }
    
});