[英]Gridster angularjs get serialized data
在gridster的有角度版本中,如何獲取序列化數據。 基本上,我需要獲取每個gridster項目的修改位置和大小。 有什么措施可以實現嗎? 在gridster的jQuery版本中,它提供了序列化選項。
我認為最好的方法是為ng-click
上的按鈕創建一個函數:
//Used to save the dashboard to BOTH local storage and PENN database
//Local storage will attempt to be loaded first. However, if local storage is not there
//then we will load the dashboard from the database
$scope.serialize = function() {
$scope.dashboardJSON = angular.toJson($scope.standardItems);
localStorageService.set("DashboardInfo", $scope.dashboardJSON);
//Send HTTP request 'POST' to saveDashboard function in Rails controller
$http({
method: 'POST',
url: 'saveDashboard',
data: {'dashboardInfo': $scope.dashboardJSON },
headers: {'Content-Type': 'application/json' }
}).success(function(data, status, headers, config)
{
//Let user know that their dashboard was saved with this success flash
$scope.successSavingDashboardToDBAlert();
}).error(function(data, status, headers, config)
{
//Let the user know the dashboard could not be saved with this error flash
$scope.errorSavingDashboardToDBAlert();
});
};
$scope.dashboardJSON
然后將如下所示:
[
{
"name": "Speedometer",
"sizeX": 2,
"sizeY": 3,
"content": "<speeometer></speedometer>",
"widgetSettings": {"id":2},
"market": "Medical",
"duration": "Monthly",
"total": 0,
"showTarget": true,
"row": 0,
"col": 0
}
]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.