将facebook登录数据放入带有angualrjs的文本字段中

时间:2016-07-16 21:35:34

标签: javascript angularjs facebook ionic-framework

我正在实施facebook登录,并且它正好用angular.but问题是当我从facebook获取数据时我无法放入文本字​​段。当我把它提醒时它能够给我数据但不能把它放在文本字段中。

 <div  ng-controller="facebook_login">
            <p align="center"><button class="icon icon-left ion-social-facebook button button-positive button-small"  ng-click="fbLogin()">Sign Up with Facebook</button></p>
            <div class="list">
                <div class="item">
                    <label class="item item-input item-stacked-label">
                        <span class="input-label">Fashion Line</span>
            <input type="text" ng-model="email" ng-value="{{data.email}}" />
         <div>

JS

.controller('facebook_login',['$scope', '$ionicModal', '$timeout', 'ngFB', function($scope, $ionicModal, $timeout, ngFB) {
 $scope.fbLogin = function () {
    ngFB.login({scope: 'email,public_profile,publish_actions'}).then(
        function (response) {
            if (response.status === 'connected') {
                //alert('Facebook login succeeded, got access token: ' + response.authResponse.accessToken);
                //$scope.closeLogin();
                 ngFB.api({
                 path: '/me',
                 params: {fields: 'first_name,last_name,gender,email,picture'}
                 }).then(
                 function (data) {
            $scope.facebook = data;
            alert(data.email)
            $scope.email = $scope.data.email;
            document.getElementById("email").innerHTML = data.email;
       });
            } else {
                alert('Facebook login failed');
            }
        });
};

}])

1 个答案:

答案 0 :(得分:0)

好像你从未定义$scope.data,但是你正在尝试使用它。你的意思是$scope.facebook.email吗?