Earphan
Earphan

Reputation: 374

Populate angular form

I have angular form which using to create some invoice, i need to add functionality to edit invoice, I am get data from db using $http and put that data in array on client side. My qusetion is how to populate data in input and select2 field from my array to not break a scope?

Upvotes: 0

Views: 2560

Answers (1)

SiCK
SiCK

Reputation: 367

I guess the array contains the lines details of the invoice (ie. $scope.invoiceDetail), you simply have to parse it with ng-repeat :

<form name="invoiceForm" novalidate>
  <div ng-repeat="line in invoiceDetail">
    <input type="text" name="itemRef" ng-model="line.reference" required>
    <input type="text" name="itemQty" ng-model="line.quantity" required>
  </div>
</form>

  $scope.invoiceDetail = [
    {reference: 123, quantity: 1},
    {reference: 456, quantity: 3},
    {reference: 789, quantity: 5},

  ];

Sorry if i misunderstood your question.

Upvotes: 2

Related Questions