- Forums
- AngularJS
- How To Show All The Elements In An Alert [object Object]
if you want to see the value of a string in javascrilpt, but when you do an alert on that string it shows [object Object] instead, this post will show you how you can display all the data [4594], Last Updated: Mon Jun 24, 2024
webune
Fri May 06, 2016
0 Comments
469 Visits
As we start to work more and more with angular and other Javascript dependent frameworks, you will run into a situation where you want to know what are the values of an element in an object.
for example, if i have an object called colors:
$scope.colors= {color: 'blue'};
and now you want to show colors in an alert like this:
alert($scope.colors);
the output will be like this:
[object Object]
to bypass and show all the values in the object, do it like this intead:
alert(JSON.stringify($scope.colors));