简体   繁体   中英

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 (ie 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 :)

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM