I put to work this way:
On the client side, I created a new folder (service) to have the service called jasonFactory on the app/script/service/jasonFactory.js.
The code for the service is:
angular.module('clientApp')
.factory('jsonFactory', function ($q, $http) {
return {
getOtherStuff: function () {
var deferred = $q.defer(),
httpPromise = $http.get('data/Employee.json');
httpPromise.then(function (response) {
deferred.resolve(response);
}, function (error) {
console.error(error);
});
return deferred.promise;
}
};
});
Also, I created a new folder (data) to have the json file called Employee.json on the app/data/Employee.json.
The content for the json file is:
{"names": [
{"name": "John"}
]}
Then, I added some code on the controller file app/script/controllers/usedController.js.
The code for the controller is:
.controller('AddCtrl', function (jsonFactory) {
$scope.otherStuff = {};
jsonFactory.getOtherStuff()
.then(function (response) {
$scope.otherStuff = response.data.names;
alert($scope.otherStuff);
}, function (error) {
console.error(error);
alert("test");
});
});
Also, the template goes like this:
<select>
<option ng-repeat="stuff in otherStuff" value="{{stuff.name}}"> {{stuff.name}}</option>
</select>