Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ReferenceError:未定义成功-Angularjs_Angularjs_Mongodb - Fatal编程技术网

ReferenceError:未定义成功-Angularjs

ReferenceError:未定义成功-Angularjs,angularjs,mongodb,Angularjs,Mongodb,我收到ReferenceError:从controller对我的node.js后端执行Restful调用时未定义成功,如下所示: authControllers.js: authControllers.controller('authCtrl', ['$scope', '$location', '$window', 'UserService', 'AuthenticationService', function authCtrl($scope, $location, $window, UserS

我收到ReferenceError:从controller对我的node.js后端执行Restful调用时未定义成功,如下所示:

authControllers.js:

authControllers.controller('authCtrl', ['$scope', '$location', '$window', 'UserService', 'AuthenticationService',
function authCtrl($scope, $location, $window, UserService, AuthenticationService) {
  $scope.me = function() {    
    UserService.me(function(res) {
      $scope.myDetails = res;
    }, function() {
      console.log('Failed to fetch details');
      $rootScope.error = 'Failed to fetch details';
    })
  };      
}]);
html:


接收到一个成功的nodeJs调用,它也返回数据,但无法在前端获取数据。请帮忙

您不能直接从angular应用程序连接到mongo,您可以使用nodejs连接到mongodb并获取数据。通过以下链接


没有办法从任何用javascript开发的框架中访问任何数据库。如果你想执行CURD操作,你需要一个服务器。首先通过nodejs。如果你想用JS编写服务器,那么你可以通过nodejs中的rest调用来帮助你开发应用程序

为了解决这个问题,我开始对PHP+Angular进行详细的解释,当时我发现这篇文章比我更详细


请看一看:

你应该在谷歌上搜索这个,而不是我搜索过的,但我没有得到任何特别的结果。@NarendraSolanki网上有几十篇关于这个的文章。还有youtube视频,它一步一步地解释了这一点。好吧,谷歌搜索给了我这么多的链接。过来看。
<div class="row" data-ng-controller="authCtrl" data-ng-init="me()">
    <div class="col-lg-12">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <strong>Your Details</strong>
            </div>
            <div class="panel-body">
                <p>{{myDetails.data.username}}</p>
                <p>{{myDetails.data.email}}</p>
            </div>
        </div>
    </div>
</div>
authServices.factory('UserService',['$http', function($http) {
  return {        
    me:function() {
    return $http.get(options.api.base_url + '/me').success(success).error(error)
    }
  }
}]);