title: How to change ng-init value with function?
body: <p>Here is my Html and JavaScript code and I want to change it through function.</p>
  
  <p><strong>Html</strong>:  </p>
  
  <pre><code>&lt;div class="container" ng-app="myApp" ng-controller="myController"&gt;
    &lt;h2&gt;{{title}}&lt;/h2&gt;
    &lt;ul ng-init="initItems()"&gt;
      &lt;li ng-repeat="item in items"&gt;
        &lt;input ng-model="item.name" type="text"/&gt;
        &lt;div ng-if="makeVisible == item.id  &amp;&amp; makeVisible !='' "&gt;
          &lt;input ng-model="newname" type="text"/&gt;
          &lt;button ng-click="hideme(item.id);  rename()" type="button"&gt;
            &lt;span class="glyphicon glyphicon-ok"&gt;
            &lt;/span&gt;
          &lt;/button&gt;
          &lt;button ng-click="hideme(item.id)" type="button"&gt;
            &lt;span class="glyphicon glyphicon-remove"&gt;
            &lt;/span&gt;
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;input ng-click=" showme( item.id)" type="button" value="Rename"/&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>JavaScript</strong>:</p>
  
  <pre><code>function item(id, name) {
      this.id = id;
      this.name = name;
  };
  
  angular.module('myApp', []).controller('myController', function($scope) {
      $scope.items = [];
      $scope.makeVisible = "";
      $scope.initItems = function() {
          $scope.items.push(new item("0", 'Vikash'));
          $scope.items.push(new item("1", 'Kumar'));
          $scope.items.push(new item("2", 'Vishal'));
          $scope.items.push(new item("3", 'Ajay'));
      };
      $scope.renameThis = function(index, oldValue) {
          console.log("oldValue==" + oldValue);
          console.log("indexx==" + index);
          var id = 'box-' + index;
          console.log("Id : " + id);
          document.getElementById(id).style.display = "block";
          console.log('jai hind');
      };
      $scope.showme = function(id) {
          $scope.makeVisible = id;
          console.log('id', id);
      };
      $scope.hideme = function(id) {
          console.log(item);
          $scope.makeVisible = "";
      };
      $scope.title = 'Enter new name here';
      $scope.rename = function() {
          $scope.item.name = $scope.newname;
          console.log('dfasdd');
      };
  });
  </code></pre>
  
  <p>Here is value in <code>ng-init</code> which is showing in input box 1 and I want to change it with value of second input box on click. how can I do this?
  I also add a function on button.</p>