My problem is that every function in my JS, is called twice. I have been reading many threads with the same problem, but I am not able to find an appropiate answer.
Here is my code:
HTML
<!doctype html>
<html ng-app>
<head>
<title>News</title>
</head>
<body ng-controller="newsCtrl">
<div>
<ul>
<li ng-repeat="item in news">
<h2>
{{item.shortFeed}}
<li class="dropdown pull-right">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Click!</a>
<ul class="dropdown-menu pull-right">
<li><a ng-click="rejectNewsItem(item)">Rechazar</a></li>
</ul>
</li>
</h2>
</li>
</ul>
</div>
</body>
<script src="js/angular.js"></script>
<script type="text/javascript" src="js/jquery-2.0.3.min.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script src="js/pruebaRest.js"></script>
</html>
JS
function newsCtrl($scope, $http) {
$http.get('http://localhost:49643/news/todaynews')
.success(function (data) {
$scope.news = data;
})
.error(function (data) { });
$scope.rejectNewsItem = function (item) {
$http.get('http://localhost:49643/news/RejectNewsItem', { params: { newsItemId: item.id } })
.success(function (data, status, headers) {
item.approved = false;
item.rejected = true;
item.selected = false;
})
.error(function (data) {
alert("error");
});
}
}
This is the whole JS I have created. I have no .config(function ($provider)) or anything else.
Here they are some snapshots of the traffic.
https://i.stack.imgur.com/7gMEG.png
https://i.stack.imgur.com/W175T.png
The one thing I want to achieve is to make an $http request the first time the page loads, so that the page fills automatically with the information taken from the server. Also, when I click a button, to call my server and remove the item from the server. But I can't afford every call is make twice.
Thank you in advance