Remove key-value if input is null in angularJS
<p>I have a form with all inputs decleared as models like "ng-model = 'input.text' ". Everything works fine but what I need is whenever the value is now null the key-value pair should be gone as well like {} not { 'text':"" }. This can be achieved if the model is required but I was wondering if this is achievable without using required.</p>

<p>The code is:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html ng-app="myApp"&gt;

  &lt;head&gt;
    &lt;link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"&gt;
    &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"&gt;&lt;/script&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;

  &lt;body ng-controller="myCtrl"&gt;
    &lt;input type="text" ng-model="input.text"&gt;
    &lt;input type="number" ng-model="input.number"&gt;
    &lt;p&gt;{{ input }}&lt;/p&gt;
    &lt;script type="text/javascript"&gt;
      app = angular.module('myApp', []);
      app.controller('myCtrl', function($scope, $timeout){
        $scope.input = {};
      });
    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The plunker is: <a href="http://plnkr.co/edit/u483ay8OZCIo9E32ssVU?p=preview" rel="nofollow">http://plnkr.co/edit/u483ay8OZCIo9E32ssVU?p=preview</a> </p>

<p><strong>PS</strong></p>

<p>The JSON value of input will be passed to the server as a JSON object through HTTP</p>