Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/42.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.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
如何将数据从node.js发送到angular.js控制器_Node.js_Angularjs - Fatal编程技术网

如何将数据从node.js发送到angular.js控制器

如何将数据从node.js发送到angular.js控制器,node.js,angularjs,Node.js,Angularjs,我使用node.js和passport进行身份验证,如果用户身份验证失败,我需要向客户端发送“login failed”消息。我的应用程序也使用express中间件。 我在客户端使用angular.js 目前,我正在使用该命令显示静态html: var loginStatus = 'Failed'; res.sendfile('views/login.html'); // What should I add/change here in order to send the loginStatus

我使用node.js和passport进行身份验证,如果用户身份验证失败,我需要向客户端发送“login failed”消息。我的应用程序也使用express中间件。 我在客户端使用angular.js

目前,我正在使用该命令显示静态html:

var loginStatus = 'Failed';
res.sendfile('views/login.html'); // What should I add/change here in order to send the loginStatus variable ?
这是我的angular.js控制器:

function MainController($scope) {
   $scope.loginStatus = // What should I write here in order to get 'Failed' ?
}

我已经把我的问题贴在上面的评论上了。

你不能。您只能使用angular.js调用node.js api,并使用回调获取返回的数据。因此,我需要在控制器模板上配置login.html的路由?如果我这样做了,我怎么能从服务器得到一个回调?是的。你应该使用角度来处理路线。angualr是一个自包含的mvc框架,您的node.js将成为您的SOA层。好的,那么我如何从服务器获取回调?您使用的是express,对吗?