来自Parse的AngularJS ng-repeat数据

时间:2021-12-19 20:37:28

I'm developing backend with Parse. I can get data from Parse but I can't show with ng-repeat with AngularJS.

我正在用Parse开发后端。我可以从Parse获取数据但是我无法使用AngularJS显示ng-repeat。

app.controller('QuestionsController',['$scope', function ($scope) {
 var query = new Parse.Query(_Categories);
 query.find().done(function(data){
     $scope.Categories = data;
     console.log($scope.Categories);
 });

 $scope.Logout = function(){
     Parse.User.logOut();
     window.location.href = '#';
 }}]);

I'm using ngRoute and this HTML codes

我正在使用ngRoute和这个HTML代码

        <div class="menu">
        <div class="container">
        <div class="bars"><i class="fa fa-bars"></i></div>
            <ul>
                <li ng-repeat="Category in Categories"><a href="#">{{Category.Name}}</a></li>
            </ul>
        </div>
    </div>

I can see data on Console but I can't show on page.

我可以在Console上看到数据,但我无法在页面上显示。

1 个解决方案

#1


0  

I solved this problem. Controller codes is

我解决了这个问题。控制器代码是

    var query = new Parse.Query(_Categories);
    query.find({
        success: function(data){
            $scope.Categories = data;
            $scope.$apply();
        }
    });

And i wrote this code on HTMl

我在HTMl上编写了这段代码

            <div class="bars"><i class="fa fa-bars"></i></div>
            <ul>
                <li ng-repeat="cat in Categories">
                    <a href="#" >{{cat.get('Name')}}</a>
                </li>
            </ul>
        </div>

#1


0  

I solved this problem. Controller codes is

我解决了这个问题。控制器代码是

    var query = new Parse.Query(_Categories);
    query.find({
        success: function(data){
            $scope.Categories = data;
            $scope.$apply();
        }
    });

And i wrote this code on HTMl

我在HTMl上编写了这段代码

            <div class="bars"><i class="fa fa-bars"></i></div>
            <ul>
                <li ng-repeat="cat in Categories">
                    <a href="#" >{{cat.get('Name')}}</a>
                </li>
            </ul>
        </div>