我这里有一段代码片段(可以正常使用),但我不明白为什么在 addReview
函数中我们还能使用 this.review
。因为 this
变量必须是用于 addReview
函数而非父函数。如果我错了,请纠正我。
app.controller('ReviewCtrl',function() {
this.review= {};
this.addReview = function(product) {
product.reviews.push(this.review);
this.review={};
}
});
this
的作用域。在父函数中使用的this
和在子函数中使用的this
应该是不同的,这看起来很琐碎。 - hard coder