'use strict';
/**
 * Widget Controller is the main Controller
 */
angular.module('myApp').controller('HomeCtrl', function($scope, Api) {
    $scope.text = 'hi';

    $scope.properties = Api.getProperties() || [];
    $scope.savedProperties = Api.getSavedProperties() || [];
    $scope.propertyAction = (options) => {
        options = options || {};
        let isSaving = options.action === 'SAVE';
        let source = isSaving ? 'properties' : 'savedProperties';
        let target = isSaving ? 'savedProperties' : 'properties';
        let property = _.find($scope[source], { id: options.id });

        $scope[target].push(property);
        $scope[source] = _.filter($scope[source], (p)=>{
        	return p.id !== options.id;
        })
    }



});

@@ -134,33 +134,8 @@
 ) %7B%0A
-    $scope.text = 'hi';%0A%0A
     
@@ -173,32 +173,32 @@
 erties() %7C%7C %5B%5D;%0A
+
     $scope.saved
@@ -334,77 +334,128 @@
 let 
-isSaving = options.action === 'SAVE';%0A        let source = isSaving ?
+actionTypes = %7B%0A            'SAVE': %7B target: 'savedProperties', source: 'properties' %7D,%0A            'REMOVE': %7B target:
  'pr
@@ -463,17 +463,24 @@
 perties'
- 
+, source
 : 'saved
@@ -494,74 +494,135 @@
 ies'
-;%0A        let target = isSaving ? 'savedProperties' : 'properties'
+ %7D,%0A        %7D%0A%0A        let source = actionTypes%5Boptions.action%5D.source;%0A        let target = actionTypes%5Boptions.action%5D.target
 ;%0A  
@@ -779,18 +779,20 @@
 ce%5D, (p)
+ 
 =%3E
+ 
 %7B%0A      
@@ -797,9 +797,12 @@
     
-%09
+    
 retu
@@ -840,17 +840,15 @@
  %7D)%0A
+
     %7D%0A%0A
-%0A%0A
 %7D);%0A

add better proxy for actions