Created
May 6, 2017 13:39
-
-
Save JBreit/5766aba8d80d3c9e912a686542966539 to your computer and use it in GitHub Desktop.
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
| /*global angular*/ | |
| (function () { | |
| 'use strict'; | |
| function config($qProvider, $stateProvider, $urlRouterProvider, $locationProvider) { | |
| $qProvider.errorOnUnhandledRejections(false); | |
| $stateProvider | |
| .state('list', { | |
| name: 'list', | |
| url: '/', | |
| templateUrl: 'components/list/templates/list.html', | |
| controller: 'ListCtrl' | |
| }); | |
| $locationProvider.html5Mode(true); | |
| } | |
| function run($rootScope, $state, $stateParams, DataService) { | |
| $rootScope.state = $state; | |
| $rootScope.stateParams = $stateParams; | |
| console.log($rootScope); | |
| } | |
| angular.module('app', ['ui.router', 'app.controllers', 'app.services.DataService']) | |
| .config(['$qProvider', '$stateProvider', '$urlRouterProvider', '$locationProvider', config]) | |
| .run(['$rootScope', '$state', '$stateParams', 'DataService', run]); | |
| }()); |
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
| /*global angular*/ | |
| (function () { | |
| 'use strict'; | |
| var dataService = function ($http) { | |
| var getData = function () { | |
| return $http.get('http://127.0.0.1:8080/data/lists.json'); | |
| }; | |
| return { | |
| getData: getData | |
| }; | |
| }; | |
| angular.module('app.services.DataService', []) | |
| .factory('DataService', dataService); | |
| }()); |
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
| /*global angular*/ | |
| (function () { | |
| 'use strct'; | |
| function ListCtrl(DataService) { | |
| var vm = this; | |
| vm.title = 'test title'; | |
| DataService.getData() | |
| //.then(console.log.bind(console), console.log.bind(console)) | |
| .then(function (response) { | |
| vm.lists = response.data; | |
| }); | |
| } | |
| ListCtrl.$inject = ['DataService']; | |
| angular.module('app.controllers', []) | |
| .controller('ListCtrl', ListCtrl); | |
| }()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment