Reputation: 101
I want to alert an object
value in AngularJs, how does one do that?
If I simply alert the object by alert(obj)
then it shows the result as object object
in alert box.
Upvotes: 4
Views: 8377
Reputation: 31576
One can log it to the console (in any browser's F12
tools) such as
console.log(obj);
or to json-ify it in the alert
popup such as
alert(angular.toJson(obj));
Upvotes: 0
Reputation: 3080
If you do it for development purpose just to see object content, much better to use inspector in Chrome or Firebug in Firefox.
You can use $log
service for that.
$log.info(obj);
This gives you advantage that you can now see object as tree and you can navigate. In alert some objects may be bigger that alert window.
Upvotes: 0