简体   繁体   中英

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.
I need to present only the values.

Javascript

$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 {} . array should be declared like this

$scope.selectedValues = [];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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