Last active
October 3, 2018 15:19
-
-
Save DevEarley/2f257934f5e76d145c1d6da50c7dcaf5 to your computer and use it in GitHub Desktop.
It's a JsonDataService
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('someApp') | |
.service('JsonDataService', function () { | |
return { | |
init: function () { | |
var thisService = this; | |
var xobj = new XMLHttpRequest(); | |
xobj.overrideMimeType("application/json"); | |
xobj.open('GET', './app/data/cm-ux-guide-data.json', true); | |
xobj.onreadystatechange = function () { | |
if (xobj.readyState == 4 && xobj.status == "200") { | |
thisService.uxGuideData = JSON.parse(xobj.responseText)[0]; | |
} | |
}; | |
xobj.send(null); | |
}, | |
uxGuideData: {}, | |
getUxGuideData: function () { | |
return this.uxGuideData; | |
}, | |
getNavigation: function () { | |
return this.uxGuideData["Navigation"]; | |
}, | |
getComponents: function () { | |
return this.uxGuideData["Components"]; | |
}, | |
getGuides: function () { | |
return this.uxGuideData["Guides"]; | |
}, | |
getNavigationByID: function (_NavigationID) { | |
return this.uxGuideData["Navigation"].Where(x => x.NavigationID == _NavigationID).toArray(); | |
}, | |
getComponentByID: function (_ComponentID) { | |
return this.uxGuideData["Components"].Where(x => x.ComponentID == _ComponentID).toArray(); | |
}, | |
getScriptByID: function (_ScriptID) { | |
return this.uxGuideData["Scripts"].Where(x => x.ScriptID == _ScriptID).toArray(); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment