Skip to content

Instantly share code, notes, and snippets.

@JBreit
Created May 6, 2017 13:39
Show Gist options
  • Select an option

  • Save JBreit/5766aba8d80d3c9e912a686542966539 to your computer and use it in GitHub Desktop.

Select an option

Save JBreit/5766aba8d80d3c9e912a686542966539 to your computer and use it in GitHub Desktop.
/*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]);
}());
/*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);
}());
/*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