Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

console.log Angular directive scope outputs "[object Object] No Properties"

Looking at the videos over at http://egghead.io, I see the author uses console.log to log out the contents of a $scope or scope object. The output in Chrome is a drillable object. However when I do the same, the output Chrome presents is:

    [object Object]
No Properties

Using console.dir has the same affect. Any recommendations?

Thanks,

like image 649
binarygiant Avatar asked May 30 '13 16:05

binarygiant


2 Answers

The + operator calls to the toString method of the object which would return '[object object]'

So using log like this:

console.log('scope is ' + scope);

Produced the string scope is [object object]

Instead use the console.log() method with commas (as commented below) to be able to drill into the scope object:

console.log('scope is', scope)
like image 120
binarygiant Avatar answered Oct 30 '22 16:10

binarygiant


Use console.log(formValues); instead of console.log("Values="+formValues);. If you use console.log("Values="+formValues); ,it is considered as string and output as [Object object]

like image 24
SIDHARTH P U Avatar answered Oct 30 '22 17:10

SIDHARTH P U