2014-02-22 41 views
0

这是我要添加密码保护,当我点击“编辑标题”我的例子hereAngular.js编辑与密码

我该怎么办?

JS代码:

function ClickToEditCtrl($scope) { 
    $scope.title = "Welcome to this demo!"; 
    $scope.editorEnabled = false; 

    $scope.enableEditor = function() { 
    $scope.editorEnabled = true; 
    $scope.editableTitle = $scope.title; 
    }; 

    $scope.disableEditor = function() { 
    $scope.editorEnabled = false; 
    }; 

    $scope.save = function() { 
    $scope.title = $scope.editableTitle; 
    $scope.disableEditor(); 
    }; 
} 

回答

0

只需创建一个$ scope.checkPassword(或有意义的事)函数,它显示了一个弹出/莫代尔/等,用户可以输入密码,然后做出一个Ajax调用来验证为密码。如果输入的密码是正确的启用编辑器,否则什么也不做或者,如果用户认证成功,您可能希望允许保存密码。

更新:

我认为密码验证应完全由服务器处理。在保存密码之前(在服务器上),我会调用处理身份验证的函数。因此,请确保您使用保存呼叫将密码作为参数发送。

+0

感谢您的回答。但你可以做一些演示吗? –