Skip to content

Instantly share code, notes, and snippets.

@achudars
Last active December 21, 2015 19:29
Show Gist options
  • Save achudars/6354471 to your computer and use it in GitHub Desktop.
Save achudars/6354471 to your computer and use it in GitHub Desktop.
AngularJS - usage of $http and getting data from an external file
'use strict';
/* Controllers */
var app = angular.module('myApp.controllers', []);
app.controller('MyCtrl1', ['$scope', '$http', function($scope, as) {
as({method: 'GET', url: 'data/data.json'}).
success(function(data, status, headers, config) {
console.log(data);
$scope.data = data;
}).
error(function(data, status, headers, config) {
});
}]);
app.controller('MyCtrl2', [function() {
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment