我想使用在控制器的相同实例之间共享的服务,但我不想为每个属性创建设置器和获取器,角度是否提供了便利?这是我想逃避的一个例子:
app.service('YtPlayerService', function(){
this.playerStatus = {
status : 'alert',
text : 'Loading The Player'
};
});
app.controller("YtPlayerController", function($scope,YtPlayerService){
$scope.playerStatus = function(){
return YtPlayerService.playerStatus;
}
$scope.setPlayerStatus = function(playerStatus){
YtPlayerService.playerStatus = playerStatus;
};
}