I have three files - app.js, controllers.js, services.js. There are a few others I want to add if I get the approach to work. I see the code going into the angular.module section of mainApp, then the services and controllers. However, no error occurs and no data is coming back and the controller methods are not called at all (only controllers are initialized from the looks of it). I tried forcing a call using init() but no luck there too. What am I doing wrong?
Here is app.js
var mainApp = angular.module('MainApp', ['test.services', 'test.controllers']);
Controllers.js
var app = angular.module('test.controllers', []);
app.controller('TestCtrl', [$scope, 'TestService', function($scope, TestService)
var promise = TestService.makeHttpRequest(../../src/testFile.json);
promise.then(function(data){
$scope.results = data;
console.log($scope.results);
});
}]);
Doesn't work. Below approach also doesn't get any data.
var app = angular.module('test.controllers', []);
app.controller('TestCtrl', [$scope, $http, function($scope, $http){
$http.get('../../src/testFile.json').then(function(data) {
$scope.results = data.data;
console.log(data);
});
}]);
services.js
var appServices = angular.module('test.services', []);
//Does the same thing, but get call moved to services
Index.html
<body class="bg-blue mainContainer" ng-app="MainApp">
<div id="content-container" ng-contoller="TestCtrl" class="container main-container">{{results}}</div>
<div id="content-container" ng-contoller="MainController" class="container main-container" ng-init="loadResults()">
</body>