2

基本的な angularJS + mongoLab アプリを作成しました。データをフェッチするコードは正常に機能し、Chrome 開発者ツールでは次のような応答を確認できます。

[ { "_id" : { "$oid" : "5166c406e4b08774fa6844a9"} , "tag" : "Software Developer"} , { "_id" : { "$oid" : "51679cbde4b05c7db8d21e70"} , "tag" : "Project Management"} ]

私の見解では:

<ul>
                <li ng-repeat="tagz in tags">
                    {{tagz.tag}}
                </li>
            </ul>

しかし、ブラウザに表示すると、

  • ドットが表示されますが、タグの値は表示されません。私のコントローラーには次のものがあります:

    'use strict';
    // Define our root-level controller for the application.
            Riadd.controller(
                "AppController",
                function( $scope, $route, $routeParams, Tags){
    
    
    
    
                    // Update the rendering of the page.
                    var render = function(){
                        $scope.tags = Tags;
    
                        // Pull the "action" value out of the
                        // currently selected route.
                        var renderAction = $route.current.action;
    
                        // Also, let's update the render path so that
                        // we can start conditionally rendering parts
                        // of the page.
                        var renderPath = renderAction.split( "." );
    
                        // Grab the username out of the params.
                        //
                        // NOTE: This will be undefined for every route
                        // except for the "contact" route; for the sake
                        // of simplicity, I am not exerting any finer
                        // logic around it.
                        var username = ($routeParams.username || "");
    
                        // Reset the booleans used to set the class
                        // for the navigation.
                        var isHome = (renderPath[ 0 ] == "home");
                        var isFriends = (renderPath[ 0 ] == "friends");
                        var isContact = (renderPath[ 0 ] == "contact");
    
                        // Store the values in the model.
                        $scope.renderAction = renderAction;
                        $scope.renderPath = renderPath;
                        $scope.username = username;
                        $scope.isHome = isHome;
                        $scope.isFriends = isFriends;
                        $scope.isContact = isContact;
    
                    };
    
                    // Listen for changes to the Route. When the route
                    // changes, let's set the renderAction model value so
                    // that it can render in the Strong element.
                    $scope.$on(
                        "$routeChangeSuccess",
                        function( $currentRoute, $previousRoute ){
    
                            // Update the rendering.
                            render();
    
                        }
                    );
    
                }
            );
    

    どこが間違っているのか分かりますか?

  • 4

    1 に答える 1

    0

    https://github.com/pkozlowski-opensource/angularjs-mongolab-promise/blob/master/README.mdを参照してください。

    私見の代わりに

    $scope.tags = Tags;
    

    必要になるだろう

    Tags.all(function(tags){
      $scope.tags = tags;
    });
    
    于 2013-04-19T15:29:25.917 に答える