28

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,

4

2 回答 2

80

+ 运算符调用将返回 '[object object]' 的对象的 toString 方法

所以使用这样的日志:

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

产生的字符串范围是[object object]

而是使用带有逗号的 console.log() 方法(如下所述),以便能够钻入范围对象:

console.log('scope is', scope)
于 2013-05-30T16:48:35.247 回答
2

使用console.log(formValues); 而不是console.log("Values="+formValues); . 如果你使用console.log("Values="+formValues); ,它被认为是字符串并输出为[Object object]

于 2018-05-15T07:01:11.293 回答