I have a controller for the landing page. My problem is that $http
gets called again whenever I view the page since the controllers for that view gets executed resulting in $http
executing all the time.
app.controller('landingCtrl', function($scope, $splash, $http, sentiment) {
//get JSON DATA FROM SERVER
var restURL = {};
restURL.getSentiments = "http://localhost:3000/getSent";
//get JSON DATA FROM SERVER
$http.get(restURL.getSentiments).then(function(res) {
log(res);
return res;
}); /*AJAX ENDS*/
});
Is there any way where I call my $http
only once or have some freedom of control as when I want to call? As of now the $http
is always getting executed.