title: Set input textbox value from another model in angularjs
body: <p>I have a html select field. I want to use the selecteditems pid attribute as a input textbox's default value. I tried the following two ways</p>
  
  <p>My select field</p>
  
  <pre><code>&lt;select ng-model="selectedProduct" ng-options="product.pname for product in products"&gt;&lt;/select&gt;
  </code></pre>
  
  <p><strong>Way 1:</strong></p>
  
  <pre><code>&lt;input type="text" data-ng-model="neworder.pid" ng-init="neworder.pid={{selectedProduct.pid}}" required /&gt;
  </code></pre>
  
  <p><strong>Way 2:</strong></p>
  
  <pre><code>&lt;input type="text" data-ng-model="neworder.pid" required /&gt;
  </code></pre>
  
  <p>and in controller</p>
  
  <pre><code>$scope.neworder.pid = $scope.selectedProduct.pid
  </code></pre>
  
  <p>But failed to make both of them work. How to do it correctly?</p>
  
  <p><strong>Update</strong></p>
  
  <p>My form containing the select field.</p>
  
  <pre><code>&lt;form name="addOrder" data-ng-show="addMode" style="width:600px;margin:0px auto;"&gt;
          &lt;select ng-model="selectedProduct" ng-options="product.pname for product in products"&gt;&lt;/select&gt;
          {{selectedProduct.pid}}
          &lt;label&gt;PID:&lt;/label&gt;&lt;input type="text" data-ng-model="neworder.pid" ng-init="neworder.pid={{selectedProduct.pid}}" required /&gt;
          &lt;label&gt;OID:&lt;/label&gt;&lt;input type="text" data-ng-model="neworder.oid" required /&gt;
          &lt;label&gt;QTY:&lt;/label&gt;&lt;input type="text" data-ng-model="neworder.qty" required /&gt;
          &lt;label&gt;TOTAL:&lt;/label&gt;&lt;input type="text" data-ng-model="neworder.total" required /&gt;
          &lt;br /&gt;
          &lt;!-- &lt;span class="error" data-ng-show="addCustomer.$error.required"&gt;Required!&lt;/span&gt;--&gt;
          &lt;br /&gt;
          &lt;input type="submit" value="Add" data-ng-click="add()" data-ng-disabled="!addOrder.$valid" class="btn btn-primary" /&gt;
          &lt;input type="button" value="Cancel" data-ng-click="toggleAdd()" class="btn btn-primary" /&gt;
          &lt;br /&gt;&lt;br /&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>add function in controller</p>
  
  <pre><code>$scope.add = function () {
              $http.post('/api/OrderDetails/', this.neworder).success(function (data) {
                  alert("Added Successfully!!");
                  $scope.addMode = false;
                  $scope.orders.push(data);
              }).error(function (data) {
                  $scope.error = "An Error has occured while Adding product! " + data;
  
              });
          };
  </code></pre>