lib/nestene/ui/public/app/application.js in nestene-0.1.3 vs lib/nestene/ui/public/app/application.js in nestene-0.1.4

- old
+ new

@@ -1,10 +1,14 @@ var window_location = window.location.pathname var nestene = angular.module('nestene', ['JSONedit']); +nestene.service('AutonTypes', function($http, $q) { + this.types = $http.get('/auton_types'); +}); + nestene.controller('AutonsController', function($scope, $http, $timeout) { $scope.autons=[]; $scope.getAutons = function() { var autonsPromise = $http.get(window_location + "autons.json"); @@ -26,20 +30,26 @@ $scope.intervalFunction(); }); -nestene.controller('CreateAutonFormController', function($scope,$http) { +nestene.controller('CreateAutonFormController', function($scope,$http, AutonTypes) { $scope.autonType = ''; $scope.createAuton = function() { var postPromise = $http.post(window_location + "autons",{auton_type: $scope.autonType}); postPromise.success(function(data, status, headers, config) { $.bootstrapGrowl("Created "+data['auton_id'], { type: 'success' }); }); postPromise.error(function(data, status, headers, config) { $.bootstrapGrowl("Could not create Auton: "+data['message'], { type: 'error' }); }); }; + $scope.auton_types = []; + AutonTypes.types.success(function(data, status, headers, config) { + console.log('auton_types:' + data); + $scope.auton_types = data; + }); + }); nestene.controller('CredentialsController', function($scope,$http) { $scope.credentials={}; $scope.loaded = false;