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