我在angularjs项目中工作,
var res = ["Art","Logic","Science"];
$scope.output = res;
结果显示为
技术,逻辑,科学
我需要结果为 -
艺术,逻辑,科学
必须在每个字符串数组值之间添加空格。
答案 0 :(得分:1)
您可以使用join()
方法来实现此目的。
var myapp = angular.module('myapp', []);
myapp.controller('SpaceCntrl', function($scope) {
var result = ["Art", "Logic", "Science"];
$scope.res = result.join(', ');
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myapp">
<div ng-controller="SpaceCntrl">
<span ng-bind="res"></span>
</div>
</div>
答案 1 :(得分:0)
答案 2 :(得分:0)
加入数组就可以了:)
var res = ["Art","Logic","Science"];
$scope.output = res.join(', ');