预填充HTML表单字段

时间:2016-04-12 21:46:22

标签: javascript mongodb mean-stack

所以我一直在尝试以html格式访问$ scope.user的元素。我的第一个想法是使用{{user.email}}例如,但似乎并非如此。我已经看到过这种方法在其他场景中的使用,但对于MEAN来说可能并非如此。

我通过查询将$ scope.user填充到mongoDB数据库中:

$http.get('/api/users/me').success(function (res) {
        $scope.user = res;
        console.log($scope.user);   // properly prints the logged in user to the console
    }).error(function (err) {
        console.log('Error');
        $scope.error = err.message;
        console.log($scope.error);
    });

我的想法是使用input元素的value属性可以用来预填充字段。例如:

<input type="text" ng-model="form.email" value="{{ user.email }}">

但这似乎不起作用。

0 个答案:

没有答案