尝试将范围属性从get请求的结果设置为soundcloud,以便在视图中使用ng-repeat显示它的元素

时间:2015-03-09 12:10:33

标签: javascript angularjs soundcloud

我正在尝试将appCtrl控制器的scope属性设置为对收藏轨道的soundcloud获取请求的结果。我想通过html表中的ng-repeat指令显示这些元素。在回调get请求时,我试图设置我的$ scope.tracks属性。

**AngularJS Controller**

var musicSetsControllers = angular.module('musicSetsControllers',[]);

//Application Controller
musicSetsControllers.controller("appCtrl", ['$scope',     function($scope,USER_ROLES, AuthService){
    //initialize client with app credentials
    SC.initialize({
        client_id:"----------",
        redirect_uri:"http://localhost:8888/music_sets/callback.html"
    })
    //initialize auth popup
    SC.connect(function(){
        console.log("in connect");
        SC.get('/me',function(me){
            alert('Hello' + me.username);
        });
        SC.get('/me/favorites', function(response){
            $scope.tracks = response;
        })
    });
}]);


**HTML Code**
<div ng-controller = "appCtrl">
    <table ng-repeat = "song in tracks">
        <td>{{song}}</td>

    </table>
    <p>test</p>
</div>

感谢您的帮助。

0 个答案:

没有答案