Hugo Seleiro
Hugo Seleiro

Reputation: 2657

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.

Upvotes: 0

Views: 315

Answers (2)

Seth Flowers
Seth Flowers

Reputation: 9190

Javascript

$scope.selectedValues = [];

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

Markup

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

Upvotes: 4

Sameer
Sameer

Reputation: 519

Problem is that you have pushing empty object into selectedValues {}. array should be declared like this

$scope.selectedValues = [];

Upvotes: 1

Related Questions