Shaheen K
Shaheen K

Reputation: 124

Display data in labels based on 1 record of data from database using AngularJS

I want to display individual column values in separate labels. I will only ever retrieve one record at any one time from my database. How can I display the columns individually (i.e. not in a table and not using ng-repeat?)

So in a dropdown I could use:

data-ng-options="c.COLUMN_1 as c.COLUMN_1 for c in tableVarSetInJS"

but I don't want a dropdown, I want a label; something like:

<label data-ng-options="c.COLUMN_1 as c.COLUMN_1 for c in tableVarSetInJS">{{COLUMN_1}}</label>

and then in a separate label:

<label data-ng-options="c.COLUMN_2 as c.COLUMN_2 for c in tableVarSetInJS">{{COLUMN_2}}</label>

Does anyone know how to do this? Many thanks in advance :)

Upvotes: 0

Views: 413

Answers (1)

tpsilva
tpsilva

Reputation: 1463

You can access the index 0 and use it's values directly.

<label>{{tableVarSetInJS[0].COLUMN_1}}</label>
<label>{{tableVarSetInJS[0].COLUMN_2}}</label>

Upvotes: 1

Related Questions