简体   繁体   English

在 angularjs 表中的两个数据库字段之间添加空格

[英]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:我的表的行是在我的 controller 中创建的,如下所示:

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"我想在 record.TotalCash 和 record.CurrencyReference 之间添加一个空格,但是如果我尝试使用此方法添加空格“字段:“record.TotalCash”+“”+“record.CurrencyReference”会出错

I have also tried using the html code  我也尝试过使用 html 代码  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/ http://jsfiddle.net/djtuavk1/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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