I am new with Angular.js, and I am following the tutorial of the angular website.
I am trying to get my data from a json file with the $http service, but nothing happens!! Even the status of the error is not working...
Here is my code:
<li>{{status}}</li>
<ul class="messages">
<li ng-repeat="message in messages">
{{message.title}}
<p>{{message.title2}} {{message.icon}}</p>
</li>
</ul>
and the js part:
var monitorControllers = angular.module('monitorControllers', []);
monitorControllers.controller('MonitorCtrl', ['$scope', '$http',
function($scope,$http) {
$http.get('data/messages.json').success(function(data, status) {
$scope.status = status;
$scope.messages = data;
}).error(function(data, status) {
$scope.messages = data || "Request failed";
$scope.status = status;
});
}]);
THE SOLUTION :
Thank you sylwester, I found the problem but it is really strange. So I just added in my js file, this: (at the beginning and the end..)
(function () {
var monitorControllers = angular.module('monitorControllers', []);
monitorControllers.controller('MonitorCtrl', ['$scope', '$http',
function ($scope, $http) {
$http.get('data/messages.json').success(function(data, status) {
$scope.status = status;
$scope.messages = data;
}).error(function(data, status) {
$scope.messages = data || "Request failed";
$scope.status = status;
});
}]);
})();
ng-controller='MonitorCtrl'in yourHTML?