2014-11-02 111 views
0

在角的在线免费课程,我看到:

app.controller('GalleryController', function(){ 
    this.current = 0; 
    this.setCurrent = function(imageNumber){ 
    this.current = imageNumber || 0; 
    }; 
}); 

但通常$scope作为参数传递给控制器​​过去了......所以,是不是真的需要?

回答

0

取决于您是否要在控制器内部使用它。由于在你的控制器中你没有使用$ scope,所以你不需要把它作为参数传递给控制器​​。

+0

我很害怕事实并非如此。当前的prop和setCurrent方法就像它们在$ scope上定义一样工作。所以它不是需要或不需要的。不管怎么说,还是要谢谢你。 – user1769128 2014-11-03 12:44:55

相关问题