Answer the question
In order to leave comments, you need to log in
How to use $http or equivalent in Angular's “Controller as” syntax?
What are the analogues, or how to include $http in Controller as syntax?
In the old version, I did this:
example.controller('exampleCtrl', [ $scope, $http, function($scope, $http) {
$http.get('/json').success(function(data, status, headers, config) {
$scope.example = data;
});
}]);
Answer the question
In order to leave comments, you need to log in
example.controller('exampleCtrl', ['$http', function($http) {
var vm = this;
$http.get('/json').success(function(data, status, headers, config) {
vm.example = data;
});
}]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question