Javascript Oauth,然后在同一页面中获取twitter提要

Javascript Oauth,然后在同一页面中获取twitter提要,javascript,angularjs,twitter,Javascript,Angularjs,Twitter,我正在使用angularjs,我正在尝试让我的Twitter身份验证和时间线代码在同一个页面上运行,而不是像我现在这样设置为2个页面 目前我有如下设置: 我的控制器: .controller('connectCtrl', function connectCtrl($scope, $rootScope, $location) { OAuth.initialize('SYd6rvZZTLQT-oJxWOeNctFuUyA'); $scope.connect = function(

我正在使用angularjs,我正在尝试让我的Twitter身份验证和时间线代码在同一个页面上运行,而不是像我现在这样设置为2个页面

目前我有如下设置: 我的控制器:

    .controller('connectCtrl', function connectCtrl($scope, $rootScope, $location) {
  OAuth.initialize('SYd6rvZZTLQT-oJxWOeNctFuUyA');
    $scope.connect = function() {
        OAuth.popup("twitter", function(err, res) {
            if (err) return alert(err);
            $rootScope.twitter = res;
            $location.path('/timeline');
            $scope.$apply();
        });
    }
})
.controller('timelineCtrl', function timelineCtrl($scope, $rootScope) {
    $rootScope.twitter.get('/1.1/statuses/home_timeline.json').done(function(data) {
        $scope.tw_timeline = data;
        $scope.$apply();
    });
})
然后是我的html: timeline.html:

  <a href="#/home" class="btn btn-success">
                            <span class="glyphicon glyphicon-user"></span>&nbsp; home
                        </a>
<ul id="timeline" ng-repeat="entry in tw_timeline">
    <li>
        <img class="thumb" src="{{entry.user.profile_image_url}}" />
        <span class="content">
            <span class="author">{{entry.user.name}}</span>
            <span class="text">{{entry.text}}</span>
            </span>
        </li>
</ul>

  • {{entry.user.name} {{entry.text}
和我的connect.html页面:

<h3>Connect with twitter to see your home timeline</h3>
<button ng-click='connect()' class="btn btn-primary">
    <img src="https://oauth.io/api/providers/twitter/logo" /> connect with twitter
</button>
连接twitter查看您的家庭时间表
连接twitter
这很好,但我想把它整合到我的主页上,在那里我还有其他的东西。我一天大部分时间都在做这件事,但我一事无成。 我可能会遇到Twitter未定义的问题或其他错误。 任何帮助都将不胜感激