title: How to have a save button with two different functionalities? like ADD and UPDATE in a save button
body: <p>It's my first time to try angular in .NET with the use of local storage and I'm still trying to understand things. I hope someone will guide me here. Here are some snippet of the code I'm trying to do.</p>
  
  <p>this is client.html:</p>
  
  <pre><code>&lt;div class="box-footer"&gt;
      &lt;button type="submit" class="btn btn-primary btn-sm" data-ng-click="vm.save()"&gt; Save&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>this is clientService.js:</p>
  
  <pre><code>// Suppose to combine SAVE and EDIT but how?
  
  function save(client) {
      var clients = [];
      if (localStorage.getItem('clients') != null)
          clients = JSON.parse(localStorage.getItem('clients'));
  
      clients.push(client);
      localStorage.setItem('clients', JSON.stringify(clients));
  }
  
  function edit(client) { 
      var clients = [];
      if (localStorage.getItem('clients') != null)
          clients = JSON.parse(localStorage.getItem('clients'));
  
      clients.forEach(function (client) {
          //compare the two ID's, if they are the same
          //Update 
      });
      //save
      localStorage.setItem('clients', JSON.stringify(clients));
  }
  </code></pre>
  
  <p>this is client.js:</p>
  
  <pre><code>var vm = this;
  vm.client = {
      id: '',
      firstname: '',
      lastname: '',
      age: ''
  };
  function edit() {
      clientService.edit(vm.client);
      getClients();
      clear();
  }
  
  function save() {
      clientService.save(vm.client);
      getClients();
      clear();
  }
  </code></pre>
  
  <p>I expect to have a save button that can add a new data and update a data after selecting from the table.</p>