我有一个简单的对象,最初被指定为:
$scope.FormService.ModeIn = "View Mode";
$scope.FormService.DeleteDis = false;
$scope.FormService.AddDis = false;
$scope.FormService.EditDis = false;
$scope.FormService.UndoDis = true;
$scope.FormService.SaveDis = true;
现在我从angularjs工厂返回更改对象:
AddDis = true;
DeleteDis = true;
UndoDis = false;
SaveDis = false;
EditDis = true;
ModeIn = "Edit Mode";
PrintDis = true;
现在我想用新的更新或更改初始值/对象属性,有人可以在这里建议我。
答案 0 :(得分:0)
我的服务:
app.service('myService', function() {
this.getResult= function () {
return {
AddDis : true;
DeleteDis : true;
UndoDis : false;
SaveDis : false;
EditDis : true;
ModeIn : "Edit Mode";
PrintDis : true;
}
}
});
在控制器中:
app.controller('myCtrl', function($scope, myService) {
var data = myService.getResult();
$scope.FormService.ModeIn = data.ModeIn ;
$scope.FormService.DeleteDis = data.DeleteDis ;
$scope.FormService.AddDis = data.AddDis ;
$scope.FormService.EditDis = data.EditDis ;
$scope.FormService.UndoDis = data.UndoDis ;
$scope.FormService.SaveDis = data.SaveDis ;
});