I'm sure there are many ways to answer this question and a lot of answers have been provided,but based on OP's question on how to send 'mode.name
' into ng-model
I've explained below using ng-options
.
In your JS
var app = angular.module('todoApp', []);
app.controller("dobController", ["$scope", "$http",
function($scope, $http) {
$scope.storageResult = {
"storageAccount": "Enable",
"user": "sdcard",
"pass": "sdcard",
"wifiIP": "0",
"ipAddr": "0",
"accessMode": [{
"name": "Local Storage",
"status": "0"
}, {
"name": "WiFi Storage",
"status": "1"
}, {
"name": "Internet Storage",
"status": "0"
}]
};
$scope.status = $scope.storageResult.accessMode[0].name;
$scope.selectedItem = '';
}
]);
In your HTML to bind mode name to ng-model follow this.
<select ng-model="status" ng-options="mode.name as mode.name for mode in storageResult.accessMode">
To bind entire object you can try below syntax
<select ng-model="status" ng-options="mode as mode.name for mode in storageResult.accessMode">
For this make small change in your JS $scope.status
like
$scope.status = $scope.storageResult.accessMode[0];
Here is a DEMO plunker