I am encountering an issue with loading JSON data before entering the main controller in my project.
Using this project as a template, I made alterations to only dist/app/home/home.js where the changes were implemented:
angular.module('WellJournal', ['uiGmapgoogle-maps', 'ngRoute'])
.config(function (uiGmapGoogleMapApiProvider, $routeProvider) {
uiGmapGoogleMapApiProvider.configure({
libraries: 'geometry,visualization,places'
});
$routeProvider.when('/', {
templateUrl: 'index.html',
controller: 'MainController',
resolve: {
markers: ['$http', function ($http) {
return $http.get('http://address/api/markers/').then(function (result) {
console.log(result.data);
return result.data;
});
}]
}
});
$routeProvider.otherwise({ redirectTo: '/' });
})
.controller('MainController', function ($scope, $uibModal) {
//trying to access $scope.markers here
}
The issue is that
markers: ['$http', function ($http) {...}]
is not being triggered. Upon checking the address of the default page being loaded (window.location.href
), it appears as file:///home/myuser/path/to/project/dir/views/index.html
(relevant code can be found here).
It seems that there is no server set up and just opening a local file (I assume?).
How can I ensure that the $routeProvider.when(...)
clause is triggered? Is this even possible?
Thank you.