字段更改后显示通知(Angular 和节点)

Display notification after field was changed (Angular and node)

我有一个输入字段,其值在失去焦点时在数据库中更新(使用 onblur)。我想做的是添加一个通知,告诉用户值已更改。

到目前为止我的代码:

HTML

<input type="text" ng-model="allsettings.pin" ng-blur="update_pin()">
<div class="alert-box notification"><span>Update: </span> {{pin_notification}}</div>

JS

$scope.update_pin = function() {
            if ($scope.allsettings.pin != undefined) {
                $scope.loading = true;
                //IF VALUE IS VALID, CALL THE UPDATEPIN FUNCTIONn
                Todos.updatepin($scope.allsettings)
                    //IF SUCCESSFUL, GET VALUE
                    .success(function(data) {
                        $scope.loading = false; 
                        $scope.formData = {}; //CLEAR FORM SO THAT USER CAN ENTER NEW DATA
                        $scope.allsettings.pin = {type : $scope.todos[0].pin}; //PASS VALUE IN OUR SCOPE    
                        $scope.allsettings.pin_notification = {type : $scope.todos[0].updated_pin}; //PASS VALUE IN OUR SCOPE
                    });
            }
        };

更新数据库

//API UPDATES PIN FOR THIS USER, RETURNS STATUS
exports.update_pin = function(req, res) {


    var pin = req.body.pin; //GET PIN VALUE FROM POSTED PARAMETER
    var response = {};
    response.updated_pin = "Your pin was updated to "+pin;

    models.login_data.update(
        {pin: pin},
        {where: {username: global_user}}
    ).then(function (result) {
        res.send(response);
    }).catch(function(error) {
        console.log('error');
    });

 };

我看到值已更新并且响应包含我要显示的消息。但是此消息永远不会显示。

视图中使用的表达式变量应该是allsettings.pin_notification而不只是pin_notification

<div class="alert-box notification"><span>Update: </span> {{allsettings.pin_notification}}</div>

成功回调的最后两行应该是

$scope.allsettings.pin = $scope.todos[0].pin;
$scope.allsettings.pin_notification = $scope.todos[0].updated_pin;

并且在 html 最后一行应该是

<div class="alert-box notification"><span>Update: </span> {{allsettings.pin_notification}}</div>