SHARE
TWEET
Untitled
a guest
Jan 24th, 2016
53
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- var app = angular.module('myApp', []);
- app.service('getDataFile', ['$http', function($http) {
- var service = this;
- service.getStream = function (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;
- });
- };
- }]);
- app.controller('MainController', ['getDataFile',
- function(getDataFile) {
- var ctrl = this;
- getDataFile.getStream('10101011').then(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.
