JavaScript filling a textarea with ng-repeat or ng-model so that it does not create a new textarea one on top of the other with the iterated data fill textarea with javascript,fill textarea with jquery,fill textarea

im having issues trying to fill a single 10 row textarea with data using ng-repeat instead it creates a new textarea for every data entry. how can i just insert into one? and i would like to make the size of the textarea dynamic to the number of entries enterd by ng-repeat

this is my js file

var WaitingRequisitionsController = function($scope, $rootScope, $modal, $window, items) {
    $rootScope.title = 'Direct Requisitions';
    $scope.items = items;

    $scope.formatDate = function (x) {
        return moment(x).format("M/D/YYYY");
    };
};

and this is my html file, specifically the area im trying to insert.

  <div class="row ">
      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
          <div class="form-group">
              <label>Items</label>
              <div ng-repeat="item in req.items">
                  <textarea ng-model="item.description" class="form-control" type="text" readonly="readonly"></textarea>
              </div>
          </div>
      </div>
  </div>

and this does the same thing

  <div class="row ">
      <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
          <div class="form-group">
              <label>Items</label>
              <textarea ng-repeat="item in req.items" class="form-control" type="text" readonly="readonly">{{item.description}}</textarea>    
          </div>
      </div>
  </div>

i have changed my js to look like this

var WaitingRequisitionsController = function($scope, $rootScope, $modal, $window, items) {
$rootScope.title = 'Direct Requisitions';
//$scope.items = items;




$scope.formatDate = function (x) {
    return moment(x).format("M/D/YYYY");
   };
};

function TodoCtrl($scope) {
  $scope.items = items.join('\n');
  $scope.$watch('items', function (items) {
    $scope.myArray = items.split('\n');
    console.log('$scope.myArray', $scope.myArray);

 });



  }

and my html to look like this

            <!-- <div class="row ">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
        <div class="form-group" ng-app>
        <label>Items</label>-->
        <div ng-app>
            <div ng-controller="TodoCtrl">
                <textarea rows={{rows}}  class="form-control" ng-model="myStr" type="text" readonly="readonly"></textarea>
            </div>
        </div>
               <!-- </div>
            </div>
        </div>-->

but nothing populates if i change this around to look like this http://jsfiddle.net/U3pVM/8165/

it works..i dont get it i need item.description i dont know if that has anything to do with it

Answer:1

Join the items into a single string, separated by newlines

var WaitingRequisitionsController = function($scope, $rootScope, $modal, $window, items) {

    $rootScope.title = 'Direct Requisitions';

    $scope.items = items
        .map(function (item) {
            return item.description;
        })
        .join('\n');

    $scope.rows = items.length;

    $scope.formatDate = function (x) {
        return moment(x).format("M/D/YYYY");
    };

};

You can then use the length of the items array to set the number or rows on the text area.

<textarea type="text" class="form-controler readonly="readonly" rows="rows"
          ng-model="items">
</textarea>

Plunker for example: http://plnkr.co/edit/SXSl4nHJi8ptufP6wTd4?p=preview

Answer:2

I have the following HEAD tag <head> <title>Test</title> <link id="css1" href="demo.css" rel="stylesheet" type="text/css"> </head> What I want to be able to in ...

I have the following HEAD tag <head> <title>Test</title> <link id="css1" href="demo.css" rel="stylesheet" type="text/css"> </head> What I want to be able to in ...

I'm learning how to use React JS with my Rails app. Disclaimer: This is the first time I am messing around with JS! I'm following a talk by Michael Chan at Rails Conf. Everything works beautifully ...

I'm learning how to use React JS with my Rails app. Disclaimer: This is the first time I am messing around with JS! I'm following a talk by Michael Chan at Rails Conf. Everything works beautifully ...

  1. react with rails 6
  2. react with rails api
  3. react with rails tutorial
  4. react with rails user authentication
  5. react with rails
  6. react with rails 5
  7. react with rails 5.2
  8. react-rails with redux
  9. react-rails with webpacker
  10. react-rails with browserify
  11. using react with rails
  12. react js with rails
  13. react native with rails
  14. integrate react with rails
  15. react router with rails
  16. react app with rails api
  17. react native with rails backend
  18. react js with rails tutorial
  19. react app with rails backend
  20. react js with rails api

I'm working on a form that has 4 different ajax request and I want to check if all 4 are successful. If they all are successful I want to switch step. Im trying something like this: If i get error ...

I'm working on a form that has 4 different ajax request and I want to check if all 4 are successful. If they all are successful I want to switch step. Im trying something like this: If i get error ...

  1. variable value jquery
  2. change variable value jquery
  3. get variable value jquery
  4. set variable value jquery
  5. update variable value jquery
  6. check variable value jquery
  7. css variable value jquery
  8. refresh variable value jquery
  9. add variable value jquery
  10. use variable value jquery
  11. access variable value jquery
  12. input value variable jquery
  13. change global variable value jquery
  14. php variable jquery value
  15. option value variable jquery
  16. attribute value variable jquery
  17. reset value variable jquery
  18. alert variable value in jquery
  19. display variable value in jquery
  20. print variable value in jquery

I want to open a popup when the user closes the last tab of the current site. The problems I have is that when the browser prompts the user (onbeforeunload returning a non null value), then the popup ...

I want to open a popup when the user closes the last tab of the current site. The problems I have is that when the browser prompts the user (onbeforeunload returning a non null value), then the popup ...

  1. javascript open popup window
  2. javascript open popup window center
  3. javascript open popup window without address bar
  4. javascript open popup with html
  5. javascript open popup after 5 seconds
  6. javascript open popup modal
  7. javascript open popup window with html
  8. javascript open popup with url
  9. javascript open popup browser window
  10. javascript open popup on page load
  11. javascript open popup new window
  12. javascript open popup window chrome
  13. javascript open popup on click
  14. javascript open popup with text
  15. javascript open popup window onclick
  16. javascript open popup window full screen
  17. javascript open popup window on page load
  18. javascript open popup in same window
  19. javascript open popup and close window
  20. javascript open popup only once