I am trying to call a node function when loading a page with angular, but for some reason the function does not get called. I have the ng-app and controller specified and I figured I would just put the api call in the controller constructor. Here is the code for the page:
<!doctype html>
<!-- ASSIGN OUR ANGULAR MODULE -->
<html ng-app="landingPage">
<head>
<!-- META -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"><!-- Optimize mobile viewport -->
<title>my page</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script src="core.js"></script>
</head>
<!-- SET THE CONTROLLER AND GET ALL GATEWAYS -->
<body ng-controller="mainController">
And then my core.js file is in the same directory which holds the controller has the controller:
var loadingCtrl = angular.module('landingPage', []);
function mainController($scope, $http) {
console.log('loading gateways');
// when landing on the page, get all gateways and show them
$http.get('/api/gateways')
.success(function(data) {
$scope.gateways = data;
console.log('got response');
console.log(data);
})
.error(function(data) {
console.log('Error: ' + data);
});
}
I never see any of the log statements....