javascript - 如何将对象转换成字符串

标签 javascript angularjs

<分区>

我在 Angular 的 $scope 中有这个值

$scope.tags = [
            { text: 'test@test.com' },
            { text: 'test1@test.com' },
            { text: 'test2@test.com' },
            { text: 'test3@test.com' }
          ];

我想要这个结果

test@test.com,test1@test.com,test2@test.com,test3@test.com 我正在尝试发送多封电子邮件

我需要循环运行吗,或者有没有其他方法可以做到这一点。

谢谢

最佳答案

您可以使用 map

tags = tags.map(function (el) {
  return el.text;
}).join(',');

Example

关于javascript - 如何将对象转换成字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27815394/

相关文章:

javascript - 如何使用 bootstrap 4 创建 3 状态复选框按钮

javascript - 编辑器 : Programatically close Find Dialog Box

javascript - Rails 中的 Ajax POST 请求错误

javascript - 获取 Div 宽度然后更新范围变量

javascript - AngularJS 的跨域请求不起作用

javascript - 为什么复制的 HTML 看起来不像原始 HTML?

javascript - 如何使用 Knex.js 向 MySQL 数据库中插入 1000 万行?

javascript - 从范围内的变量渲染 Angular 的 html

angularjs - 在 AngularJS 中使用重复键迭代 json 响应

angularjs - Angular 模型的依赖属性