0
我的應用程序中有以下表格,用戶可以在其中設置通知首選項。使用角度js重置表格偏好
-
當頁面加載$ ctrl.getNotificationSettings(
- )將被調用,它會列出各種categories.please用戶通知首指截圖
- 我也寫一個$ ctrl.save(),它允許用戶更新他們的偏好,並保存它的工作正常。
- 現在我有一個$ ctrl.cancelSettings()的重置按鈕,在這裏我希望用戶能夠改變一些偏好,如果他決定在保存之前恢復它,表應該與偏好設置它是如何加載時。這部分需要一些幫助。
由於其他一些挑戰,我不能在這裏使用表格。
HTML
<tbody>
<tr data-ng-repeat="app in $ctrl.notificationSettings" class="content-box">
<td data-ng-bind="app.appName"></td>
<td><ng-checkbox data-checked="app.email" rounded="true"></ng-checkbox></td>
<td><ng-checkbox data-checked="app.sms" rounded="true"></ng-checkbox></td>
</tr>
</tbody>
</table>
<div class="content-box">
<button class="ng-button-primary" data-ng-click="$ctrl.saveSettings()">Save</button>
<button class="ng-button-secondary" data-ng-click="$ctrl.cancelSettings()">Reset</button>
</div>
JS
$ctrl.getNotificationSettings = function() {
var url = "http://localhost:3000/json/notification-settings.json";
rsicontext.getData(url).then(function (response) {
$ctrl.notificationSettings = response.data;
$ctrl.appName = response.data.appName;
$ctrl.emailNotification = response.data.email;
$ctrl.smsNotification = response.data.sms;
});
};
$ctrl.cancelSettings = function() {
console.log("cancel settings");
};
JSON格式列出數據
[{
"appName":"Finance",
"email":true,
"sms":false
},
{
"appName":"Sports",
"email":true,
"sms":true
},
{
"appName":"Economics",
"email":false,
"sms":false
},
{
"appName":"Health",
"email":false,
"sms":true
}]
你想在哪裏使用表單? – Codesingh