Skip to content

Commit

Permalink
Merge pull request #13 from kelseyledford/users
Browse files Browse the repository at this point in the history
Users
  • Loading branch information
mikewong79 committed Jun 25, 2014
2 parents f7a9550 + c5458c9 commit 64594e1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 45 deletions.
87 changes: 42 additions & 45 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
'use strict';

var LaApp = angular.module('LaApp', ["ui.router", "mgcrea.ngStrap", 'mgcrea.ngStrap.modal', 'google-maps', 'ngResource']);

LaApp.config(function($stateProvider, $urlRouterProvider, $httpProvider) {
var defaults = $httpProvider.defaults.headers;
// var defaults = $httpProvider.defaults.headers;

// defaults.patch = defaults.patch || {};
// defaults.patch['Content-Type'] = 'application/json';
// defaults.post['Content-Type'] = 'application/json';
// defaults.common['Accept'] = 'application/json';


defaults.patch = defaults.patch || {};
defaults.patch['Content-Type'] = 'application/json';
defaults.common['Accept'] = 'application/json';
//Reset headers to avoid OPTIONS request (aka preflight)
// $httpProvider.defaults.headers.common = {};
// $httpProvider.defaults.headers.common['Content-Type'] = 'application/json; charset=utf-8';
// $httpProvider.defaults.headers.post = {};
// $httpProvider.defaults.headers.put = {};
// $httpProvider.defaults.headers.patch = {};
// delete $httpProvider.defaults.headers.common["X-Requested-With"];

// For any unmatched url, redirect to start modal
$urlRouterProvider.otherwise("/start");
Expand Down Expand Up @@ -131,50 +143,35 @@ LaApp.factory('User', ['$resource', function($resource) {
LaApp.controller('NewUserCtrl', ['$scope', 'User', '$state', function($scope, User, $state) {
$scope.users= [];

$scope.newUser = new User();

User.query(function(users) {
$scope.users = users;
});
});

$scope.saveUser = function () {
$scope.newUser.$save(function(user) {

$scope.newUser = new User();

$scope.saveUser = function() {
console.log($scope.newUser);
$scope.newUser.$save(function() {
$state.go('start');
});
}
};
}]);

// $scope.deleteYogurt = function (user) {
// yogurt.$delete(function() {
// position = $scope.users.indexOf(user);
// $scope.users.splice(position, 1);
// }, function(errors) {
// $scope.errors = errors.data
// });
// }

// $scope.showYogurt = function(user) {
// yogurt.details = true;
// yogurt.editing = false;
// }

// $scope.hideYogurt = function(user) {
// yogurt.details = false;
// }

// $scope.editYogurt = function(user) {
// yogurt.editing = true;
// yogurt.details = false;
// }

// $scope.updateYogurt = function(user) {
// yogurt.$update(function() {
// yogurt.editing = false;
// }, function(errors) {
// $scope.errors = errors.data
// });
// }

$scope.clearErrors = function() {
$scope.errors = null;
}
}])
LaApp.controller('ShowUserCtrl', ['$scope', 'User', '$stateParams', function($scope, User, $stateParams) {
User.get({id: $stateParams.id}, function(user) {
$scope.user = user;
});
}]);

LaApp.controller('EditUserCtrl', ['$scope', 'User', '$stateParams', '$state', function($scope, User, $stateParams, $state) {
User.get({id: $stateParams.id}, function(user) {
$scope.user = user;
});

$scope.update = function() {
$scope.user.$update(function() {
$state.go('start');
});
};
}]);
1 change: 1 addition & 0 deletions partials/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ <h1 id="signup-header">Sign Up</h1>
<button id="signup-submit" type="submit" class="button button-block button-positive">Save!</button>
</form>
</div>
{{users}}
</div>

0 comments on commit 64594e1

Please sign in to comment.