I am trying to get my <select>
to show every Route that is contained in the file routes.json
. However, when I am using the ng-option, I can't seem to work out the correct expression to do so.
This is the data that gets loaded. I want to put the destination of that route into the select box.
HTML:
<label>Route: </label> <select ng-model = "selectBox2" ng-options="Route.destination for Route in data"> </select>
Controller Code:
kpsApp.controller('addMailItemController', function($scope,filefetch){
$scope.price = 'priceless';
filefetch.fetch().then(function(data){
$scope.dataRoute = data;
})
});
EDIT
Route.json:
{
"Route": {
"objectId": "ObjectRef",
"origin": "Sydney",
"destination": "Rome",
"type": "Air",
"maxWeight":"5000",
"maxVolume":"29000",
"wieghtCost":"1000",
"volumeCost":"1000",
"duration": "18hrs",
"frequencyOfDeparture": "2 daily",
"day":"Thursday",
"company":"Transport Co.",
"weightPrice":"7",
"volumePrice":"5",
"priority": "International Air"
}
}
EDIT 2
fileFetch method
kpsApp.factory('filefetch', function($q, $timeout, $http) {
var getFile = {
fetch: function(callback) {
var deferred = $q.defer();
$timeout(function() {
$http.get('../route.json').success(function(data) {
deferred.resolve(data);
});
}, 30);
return deferred.promise;
}
};
return getFile;
});