简体   繁体   中英

Adding a space between two database fields in an angularjs table

I am trying to put a space between two database values that are in the same column of my table, but I keep getting errors.

The rows for my table are created in my controller like this:

private createRow() {

     if(!this.$scope.fromTransfers){
         return [
            {cols: [{title: "Name:", field: "record.Name"}, {title: "Created:", field:"record.Created"}]},
            {cols: [{title: "Total Quantity:", field: "record.TotalQuantity"}, {title: "Total Cash:", field: "record.TotalCash + record.CurrencyReference"}]},

I want to add a space between record.TotalCash and record.CurrencyReference, but I get errors if I try adding a space using this method "field: "record.TotalCash" + " " + "record.CurrencyReference"

I have also tried using the html code   for a space, but it also produces an error. I don't want to have to separate these two values into two columns.

What's the proper way to do this?

+" "+ is the correct way, to add space, what's your error?

 let data = [{ cols: [ {title: "Name:", field: "record.Name"}, {title: "Created:", field:"record.Created"} ] }, { cols: [ {title: "Total Quantity:", field: "record.TotalQuantity"}, {title: "Total Cash:", field: "record.TotalCash" + " " + "record.CurrencyReference" }] }]; let record = {TotalCash: 100, CurrencyReference: '123'}; let field = `${record.TotalCash}` +" "+ `${record.CurrencyReference}`; console.log(field); console.log(data);

http://jsfiddle.net/djtuavk1/1/

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