Reputation: 2126
I am triyng to reach a simple app that return result from a MongoDB I am getting this error in the console;
Uncaught TypeError: Cannot read property 'controller' of undefined at model.js:8
'use strict';
var mid = angular.module('mid', [
'ngRoute'
]).
mid.controller('pageCtrl', function($scope, $http){ <------- This line
$scope.pages = [];
$http({
method: 'GET',
url: 'http://127.0.0.1/pages'
})
.then(function(pages) {
$scope.pages = pages.data;
})
.catch(function(errRes) {
// Handle errRess
});
});
What am I doing wrong?
Upvotes: 0
Views: 71
Reputation: 222582
Remove the .
after declaring module
var mid = angular.module('mid', [
'ngRoute'
])
DEMO
'use strict';
var mid = angular.module('mid', [])
mid.controller('pageCtrl', function($scope, $http){
$scope.display = "test";
});
<!DOCTYPE html>
<html ng-app="mid">
<head>
<script src="https://code.angularjs.org/1.2.1/angular.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body ng-controller="pageCtrl">
{{display}}
</body>
</html>
Upvotes: 2