0

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.

3
  • 1
    initialise it as $scope.selectedValues = [] Commented Nov 19, 2018 at 14:31
  • 1
    display it as <div>{{selectedValues.join(" ")}}</div> Commented Nov 19, 2018 at 14:34
  • Thank you all !! Commented Nov 19, 2018 at 14:47

2 Answers 2

4

Javascript

$scope.selectedValues = [];

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

Markup

<div>
  <span ng-repeat="value in selectedValues">{{value}}</span>
</div>
Sign up to request clarification or add additional context in comments.

Comments

1

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

$scope.selectedValues = [];

1 Comment

Sammer , Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.