title: Adding data to json object dynamically using angularjs
body: <p><strong>This is MY program for dynamically adding name contact to json data</strong>
  The program is working fine and showing adding data my list objects while running the program  but the problem is  data can't be saved in my program
  Please help to me</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
   &lt;html ng-app="Myapp"&gt;
   &lt;head&gt;
   &lt;meta name="viewpoint" content="width=device-width,intial-scale=1"&gt;
    &lt;meta charset="utf-8"&gt;
     &lt;link rel="stylesheet" href="D:\java practice\bootsrap\bootstrap.min.css"&gt;
    &lt;script src="D:\java practice\bootsrap\bootstrap.min.js"&gt;
    &lt;/script&gt;
    &lt;script src="D:\java practice\bootsrap\jquery.min.js"&gt;
    &lt;/script&gt;
    &lt;meta name="Generator" content="EditPlus"&gt;
    &lt;meta name="Author" content=""&gt;
    &lt;meta name="Keywords" content=""&gt;
    &lt;meta name="Description" content=""&gt;
    &lt;link rel="stylesheet" href="D:\java practice\bootsrap\bootstrap.min.css"&gt;
    &lt;script src="D:\java practice\bootsrap\bootstrap.min.js"&gt;
    &lt;/script&gt;
    &lt;script src="D:\java practice\bootsrap\jquery.min.js"&gt;
    &lt;/script&gt;
   &lt;script src="D:\java practice\angular\angular2.js"&gt;&lt;/script&gt;
   &lt;/head&gt;
  
   &lt;body&gt;
  &lt;div ng-controller="Mycntrl"&gt;
  &lt;form class="form-inline" role="form"&gt;
  Name:&lt;input type="text" name="Name" ng-model="name" class="form-control" placeholder="Enter your Name"&gt;
  Contact:&lt;input type="text" name="contact" ng-model="contact" class="form-control" placeholder="Contact"&gt;
  &lt;ul ng-repeat="person in persons" ng-show="Myshow"&gt;
      &lt;li&gt;{{person.name}}&lt;/li&gt;
      &lt;li&gt;{{person.contact}}&lt;/li&gt;
  &lt;/ul&gt;
  &lt;/form&gt;
  &lt;button class="btn btn-default" type="button" name="Show" ng-click="Myfun()"&gt;Show&lt;/button&gt;
  &lt;button class="btn btn-default" type="button" name="Save" ng-click="save()"&gt;Add Contact&lt;/button&gt;
  &lt;/div&gt;
    &lt;script&gt;
  var app=angular.module("Myapp",[]);
    app.controller("Mycntrl",function($scope) {
        $scope.name="";
        $scope.contact="";
        $scope.Myshow=false;
        $scope.persons=[
        {name:'Macha Devendher',contact:'1234567890'},
        {name:'Macha Devendher1',contact:'9876543210'},
        {name:'Macha Devendher2',contact:'1472583690'}
        ];
  
  $scope.save=function() {
      if($scope.contact.length&lt;10)
      {
          alert("Please enter valid contact number");
      }
      else {
  
      $scope.persons.push({ 'name':$scope.name,'contact':$scope.contact });
      $scope.name="";
      $scope.contact="";
      alert("You are contact number added succesfully");
      }
      }
      $scope.Myfun=function() {
         $scope.Myshow=!$scope.Myshow;
      }
    }
   );
    &lt;/script&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>