R. Mani Selvam
R. Mani Selvam

Reputation: 320

How can i Bind or copy one input value into another input using of angularjs?

My Code :-

<div>
    <label >Upload Img</label>
  <input ng-model="img" role="uploadcare-uploader" name="content" data-public-key="240426036fd9daf2d723" data-images-only />

</div>

<div>
    <label for="quantity">Fetch above input value in this input</label>
    <input type="text" ng-model="userimg" ng-bind="userimg=img" value="{{img}}">

</div> 

Upvotes: 0

Views: 226

Answers (2)

Kusum Kushwaha
Kusum Kushwaha

Reputation: 202

I have one temporary solution for your question as you are using angularJS 1 version

   <div>
      <label >Upload Img</label>
      <input id="fileId" role="uploadcare-uploader" name="content" data-public- 
       key="240426036fd9daf2d723" data-images-only />  
   </div>
   <div>
     <label for="quantity">Fetch above input value in this input</label>
     <input type="text" ng-model="userimg">         
     <input type="submit" value="Set">
   </div> 

and in controller

$scope.userimg = null;
$(':submit').on('click', function() {
  var input = $('#fileId');

  $scope.userimg = input[0].value;
  $scope.$apply();
})

On click of set button, you will get the value. As you are using this library https://ucarecdn.com/libs/widget/3.3.0/uploadcare.full.min.js I can give this temporary solution

if you are using angularJs 1 any version then use angular-uploadcare library

https://github.com/uploadcare/angular-uploadcare

and if you are using angular 2 or above version then use ngx-uploadcare-widget https://github.com/uploadcare/ngx-uploadcare-widget

Upvotes: 1

Sujan Gainju
Sujan Gainju

Reputation: 4769

You just have to display the img variable in the text field for <label for="quantity">.

In ts file declare a variable img

 img; 

In html file

<div>
     <label >Upload Img</label>
      <input [(ngModel)]="img" role="uploadcare-uploader" name="content" data-public-key="240426036fd9daf2d723" data-images-only />

    </div>

    <div>
        <label for="quantity">Fetch above input value in this input</label>
        <input type="text" [(ngModel)]="img" value="{{img}}">

    </div> 

Upvotes: 0

Related Questions