| 1234567891011121314151617181920212223242526272829303132333435 |
- angular.module('basicFoodEditor', ['ngResource'])
- .factory('BasicFood', ['$resource', '$q', function($resource, $q) {
- return $resource('food/:id', {}, {
- 'get': {method: 'GET'},
- 'query': {method: 'GET', isArray: true},
- 'save': {method: 'PUT'},
- 'update': {method: 'POST'},
- 'delete': {method: 'DELETE'}
- });
- }])
- // TODO: Only ever used with editBasicFood template. See if can auto link.
- .controller('BasicFoodEditorController',
- ['$scope', '$uibModalInstance', 'BasicFood', 'foodData',
- function($scope, $uibModalInstance, BasicFood, foodData) {
- if (foodData == null)
- {
- console.error("No food data to edit!");
- return;
- }
-
- $scope.food = new BasicFood(foodData);
- $scope.submit = function(food) {
- food.$save($scope.close, function (err) {
- // TODO: Proper error handling
- console.error(err);
- });
- };
- // TODO:
- // Will this controller ever be used non-modally?
- // Will it even work as a non-modal?
- $scope.close = $uibModalInstance != null?
- $uibModalInstance.close : null;
- }]);
|