'use strict';

angular.module('core').controller('itemController', ['$scope', 'Authentication', 'itemService',
	function($scope, Authentication, itemService) {
		// This provides Authentication context.
		$scope.authentication = Authentication;
	
	// Some example string - remove in prod
        $scope.helloText = 'Item Test';
        $scope.testuser = $scope.authentication.user.displayName;


    	$scope.items = itemService.query();
		$scope.newItem = '';
		$scope.UPCnumber = '';
//	$scope.post = function() {
//		$scope.items.push($scope.newItem);
//		$scope.items.push({created_by: $scope.authentication.user.displayName, UPC: $scope.newItem, created_at: Date.now()}, 
//		function(){
//			$scope.items = itemService.query();
//			$scope.newItem = '';	
//		});
//	};

	$scope.post = function() {
//	  $scope.newItem.created_by = $scope.authentication.user._id;
//	  $scope.newItem.created_at = Date.now();
//	  $scope.newItem.UPC = $scope.UPCnumber;
	  itemService.save({UPC: $scope.UPCnumber}, function(){
	    $scope.items = itemService.query();
	    $scope.newItem = '';
	  });
	};
	
	$scope.delete = function(item)	{
		itemService.delete({id: item._id});
		$scope.item = itemService.query();
	};

	}
]);

@@ -478,18 +478,18 @@
 r = '';%0A
-//
+%0A%0A
 %09$scope.
@@ -512,316 +512,29 @@
 ) %7B%0A
-//%09%09$scope.items.push($scope.newItem);%0A//%09%09$scope.items.push(%7Bcreated_by: $scope.authentication.user.displayName, UPC: $scope.newItem, created_at: Date.now()%7D, %0A//%09%09function()%7B%0A//%09%09%09$scope.items = itemService.query();%0A//%09%09%09$scope.newItem = '';%09%0A//%09%09%7D);%0A//%09%7D;%0A%0A%09$scope.post = function() %7B%0A//%09  $scope.newItem.
+%09  itemService.save(%7B
 crea
@@ -539,18 +539,17 @@
 eated_by
- =
+:
  $scope.
@@ -575,120 +575,10 @@
 ._id
-;%0A//%09  $scope.newItem.created_at = Date.now();%0A//%09  $scope.newItem.UPC = $scope.UPCnumber;%0A%09  itemService.save(%7B
+, 
 UPC:

Update item.client.controller.js