我需要在angularjs中没有数组括号的输出值

Bha*_*jan 1 javascript angularjs

我为我的项目使用了清单模型插件.它运作良好.但我需要没有数组括号的输出值.例如,如果我在代码中选择了20 c复选框,则会显示["20 c"].但在这里我需要输出"20 c".

我的HTML代码

<div ng-controller="Ctrl1" >
<label ng-repeat="temp in temps">
  <input type="checkbox" checklist-model="tempValue.temps" checklist-value="temp"> {{temp}}
</label><br />
<input type="text" value="{{tempValue.temps}}"  />
</div>
Run Code Online (Sandbox Code Playgroud)

我的控制器代码

app.controller('Ctrl1', function($scope) {
  $scope.temps = [
    '18 C ', 
    '19 C ', 
    '20 C ', 
    '21 C ',
    '22 C ', 
    '23 C ', 
    '24 C ', 
    '25 C ',
    '26 C ', 
    '27 C ', 
    '28 C ', 
    '29 C ',
    '30 C '
  ];
  $scope.tempValue = {
    temps: ['20 C ' , '24 C ' ]
  };

});
Run Code Online (Sandbox Code Playgroud)

ozn*_*znu 5

如果您只想显示$scope.tempValue阵列中的第一个项目,您可以执行以下操作:

{{ tempValue.temps[0] }}
Run Code Online (Sandbox Code Playgroud)

如果您希望列出所有值,请使用某个分隔符(在此示例中为逗号)进行拆分 - 您可以执行以下操作:

{{ tempValue.temps.join(', ') }} 
Run Code Online (Sandbox Code Playgroud)