SHARE
TWEET
Untitled
a guest
Jan 24th, 2016
44
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- var app = angular.module('myApp', []);
- app.factory('getDataFile', ['$http', function($http) {
- function getStream(pid) {
- return $http.get("data/" + pid + ".json")
- .then(function(data) {
- console.info("Found data for pid " + pid);
- return data;
- })
- .catch(function(err) {
- console.error("Cant find data for pid " + pid);
- return err;
- });
- }
- return {getStream: getStream};
- }]);
- app.controller('MainController', ['$scope', 'getDataFile',
- function($scope, getDataFile) {
- var ctrl = this;
- getDataFile.getStream('10101011').success(function(data) {
- ctrl.myVar = data.someField; // etc etc etc
- });
- }]);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
