简体   繁体   English

AngularJS-在前端显示数组值

[英]AngularJS - Show the array values on front end

I'm pushing values to an array that came from a select box to accomplish that, I'm doing this: 我正在将值推送到来自选择框的数组来完成此操作,我正在这样做:

$scope.selectedValues = [{

}]

$scope.print = function() {
  $scope.selectedValues.push($scope.model);
}
<div>{{selectedValues}}</div>

What I see in my front end is the array whit the values [{},"01","02"] and not the values only. 我在前端看到的是值[{},"01","02"]而不是仅值的数组。
I need to present only the values. 我只需要介绍这些值。

Javascript Java脚本

$scope.selectedValues = [];

$scope.print = function() {
  $scope.selectedValues.push($scope.model);
};

Markup 标记

<div>
  <span ng-repeat="value in selectedValues">{{value}}</span>
</div>

Problem is that you have pushing empty object into selectedValues {} . 问题是您已将空对象推入selectedValues {}中 array should be declared like this 数组应该这样声明

$scope.selectedValues = [];

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

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