Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I'm displaying list of values fetched from DB. One of its attributes is array. I handled it using table as below,

<tr>
  <td>{{movId}}</td>
  <td>{{movtitle}}</td>
  <td>
    <ul>
      <li ng-repeat="mem in mov.cast>{{mem}}</li>
    </ul>
  </td>
</tr>

But i've changed it to display in text box instead of table so that i can edit as below,

<input type="text" ng-value="movId">
<input type="text" ng-value="movtitle">

I don't know how to display array attribute ("Cast") in text box

How to attain this...Hope it is possible...if not any alter way to handle it??

share|improve this question
    
You may want to take a look at ngTagsInput. – Nikos Paraskevopoulos Mar 30 at 8:08
    
@NikosParaskevopoulos M not gona type in UI mate...rather i would like to display in UI. – Vino Spartan Mar 30 at 8:13
up vote 1 down vote accepted

You can use ng-model:

<input type="text" ng-value="movie.movTitle" ng-model="movie.movTitle"/>

I don't know how your data is structured exactly, but you could do it like this:

$scope.movies = [
    {
        movId:1234,
        movTitle:'gone with the wind',
        cast:[
            'bill',
            'ben',
            'bart'
       ]
    }
]

HTML:

<table ng-repeat="movie in movies">
  <tr>
      <td>
          <input type="text" ng-value="movId" ng-model="movie.movId"/>
      </td>
      <td>
          <input type="text" ng-value="movie.movTitle" ng-model="movie.movTitle"/>
      </td>
  </tr>
  <tr>
      <td ng-repeat="item in movie.cast">
          <input type="text" ng-value="item" ng-model="item"/>
      </td>
  </tr>

</table>

Demo

share|improve this answer
    
Thnks mate..that resolved the prob. But the 4 text boxes are listed horizontally if cast has 4 values. I want it to be vertical..i used <br> --not working!? – Vino Spartan Mar 30 at 8:24
    
@VinoSpartan you're welcome - please accept the answer :) To display the cast vertically, you could use the ng-repeat in the table row rather than the table cell. EG: jsfiddle.net/x3y9p0s2/1 – Tony Barnes Mar 30 at 8:27
    
No i can't use it so. Because i've one more <td>'s for all to display what it is... Ex : <tr> <td>Cast Details></td> <td><input type="text" ng-value="item" ng-model="item"/></td> </tr> If i replace ng-repeat n place in tr means i'll get tf--> Cast Details as much times as values in UI – Vino Spartan Mar 30 at 8:34
    
@VinoSpartan I'm not sure what you mean exactly, if you get an example up I can take a look. – Tony Barnes Mar 30 at 8:39
    
Actually for prob point of view i missed a td in my question. Original code is <tr> <td>Cast Details</td> <td ng-repeat="item in cast"><input type="text" ng-value="item" ng-model="item"/></td> So as you suggested, if i replace the ng-repeat to my <tr> then my first <td>Cast Details</td> also will display many times as much as item value – Vino Spartan Mar 30 at 8:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.