Tag: angularjs

新手用Karma,Node.js和Jasmine尝试AngularJS

我得到这个错误运行脚本/ test.bat通过控制台 Chrome 48.0.2564 (Windows 7 0.0.0) ERROR Uncaught TypeError: Cannot read property 'module' of undefined 我在Windows 7下,你可以注意到并使用Angular Seed。

ng-switch导致上传错误

我用这个链接nodejs + multer + angularjs中的答案进行上传,而不用redirect在angularjs中进行file upload。 这完美的作品。 根据我的要求,我编辑了angular度html文件的代码(添加了ng-switch): <div ng-switch="MyVar"> <div ng-switch-when="car"> <input type="file" file-model="myFile"/> <button ng-click="uploadFile()">Upload</button> </div> <div ng-switch-when="dog"> dog </div> </div> 所有其他文件完全相同。 ng-switch工作正常。 但在这个更改后,我的file upload不会工作(导致服务器错误,因为没有文件发送)。 我的意思是,如果我删除开关部分在链接,那么它工作正常。 即使在select文件后,$ scope.myFile也显示为空。 为什么ng-switch导致问题? 请帮忙

在Angular js的每个请求头添加访问令牌

我正在使用节点js rest api。 在authentication过程中,api返回一个访问令牌。 我需要将访问令牌添加到来自普通地点的每个请求。

npm安装后注入angular度资源

我试图在我的MEAN应用程序中实现angular-resource 。 我跑npm install angular-resource –save ,现在我想注入使用 angular.module('myApp', ['ui.router', 'angular-resource']) 但是我得到了典型的Error: [$injector:modulerr] 。 我究竟做错了什么?

离子套接字设置不起作用

我使用MEAN.JS (NODEJS)为我的服务器端和客户端为我的门户网站,我有套接字安装实时更新和它的作品完美,当我在我的ionic framework基于Android应用程序中使用相同的控制器它吐出错误, GET http://localhost:8100/socket.io/?EIO=3&transport=polling&t=LDaenOH 404 (Not Found) 。 我的服务器在http://localhost:3000 我的MEANJS和IONIC套接字服务 angular.module('core').service('Socket', ['Authentication', '$state', '$timeout', function (Authentication, $state, $timeout) { // Connect to Socket.io server this.connect = function () { // Connect only when authenticated if (Authentication.user) { this.socket = io(); } }; this.connect(); // Wrap the Socket.io 'on' method this.on = function (eventName, callback) […]

angularNgRoute“/”的作品,但其余的不?

我有一个应用程序在MEAN堆栈上运行,我似乎无法获得除“/”之外的任何angular度path。 我已经尝试了ng-Route和ui-router,并且都不断的发送“/”以外的任何东西(比如/ contacts或者/ portfolio_item / 4)回到“/”。 这里是app.js: // using the express library in variable express var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); // specify that app is a new express application var app = express(); app.use('/javascripts', express.static(__dirname + […]

Node API – 如何将Facebooklogin链接到Angular前端?

重写这个问题更清楚。 我已经使用passport-facebook在我的网站上处理与Facebook的login。 我的前端是在Angular,所以我现在知道需要了解什么是调用API路线的正确方法。 我已经有几个使用Angular的$http服务调用 – 但是作为这个login与Facebook实际上重新路由的Facebook页面,我仍然可以使用通常的: self.loginFacebook = function )() { var deferred = $q.defer(); var theReq = { method: 'GET', url: API + '/login/facebook' }; $http(theReq) .then(function(data){ deferred.resolve(data); }) return deferred.promise; } 或者它是完全正确/安全/正确的程序,直接在窗口位置中的URL: self.loginFacebook = function (){ $window.location.href = API + '/login/facebook'; } 而且,从这个我怎样才能从API发回一个令牌? 我似乎无法修改callback函数来做到这一点? router.get('/login/facebook/callback', passport.authenticate('facebook', { successRedirect : 'http://localhost:3000/#/', failureRedirect : 'http://localhost:3000/#/login' […]

错误“临时标题显示”在铬上

我创build了一个API,当我调用它必须从数据库中删除图像。 作为我使用MongoDB的数据库,并使用gridfspipe理图像。 这是调用API从数据库中删除图像的代码。 vm.delete = function(img){ $http.delete(baseImage + img) .success(function(data){ console.log(data); }).error(function(error){ console.log(error); }); }; 这是API的代码 gfs.exist({_id: req.params._idImg}, function (err, found) { if(found){ gfs.remove({ _id: req.params._idImg }, function (err) { if(err){ throw err; } repliesManager(res, 200, {"message":"OK"}, "OK"); }); } }); 但是,当我调用这个API,图像被清除,但服务器停止,结果是一个错误。 只有当您使用Chrome时,才会出现此错误,并且错误为“临时标题显示”。 这是AnswersManager的代码 module.exports = function(res, status, data, message, err) { var respObj = […]

Meteor方法对客户端返回undefined(asynchronous)

我一直在努力将Google Recaptcha整合到Meteor和AngularJS Web应用程序中。 一切都很顺利,直到我必须validationrecaptcha响应 – 由于一些奇怪的原因,我无法从后端到前端获得asynchronous响应。 我已经尝试了很多不同的变体,并且在SO和互联网上阅读了很多很多的post,但没有运气 – 所以我select发布自己的问题。 这是我正在做的事情: 客户: Meteor.call('recaptcha.methods.validateRecaptcha', { 'response' : this.recaptcha.getResponse(this.id) }, function(error, result) { // error and result are both undefined console.log('Do something with the ' + error + ' or ' + result + '.'); } 所以,我打电话给一个Meteor方法,并传入一个方法完成后运行的callback函数。 但是, error和result参数都是未定义的。 服务器: run: function(data) { if (this.isSimulation) { /* * […]

AngularJS $ http.post()返回404

我一直在尝试通过Shiva Adhikari的教程“AngularJs,Node js,Express js,Bootstrap,EJS,MySQL的CRUD应用程序”学习,当时我意识到自己被困在教程的第5部分。 我的问题 提交表单以创build产品类别时,浏览器控制台会报告以下错误 我的代码在表单提交时被调用 angular.module("productCategoryModule") .factory("productCategoryService", productCategoryService); productCategoryService.$inject = ['$http']; function productCategoryService($http) { return { createProductCategory: function(productCategory) { return $http.post('/createProductCategory', { categoryName: productCategory.categoryName, categoryDetails: productCategory.categoryDetails }); /* return $http({ method: 'POST', url: '/createProductCategory', data: { 'categoryName' : productCategory.categoryName, 'categoryDetails' : productCategory.categoryDetails }, headers: {'Content-Type': 'application/x-www-form-urlencoded'} });*/ }, getAllProductCategories: function() { return $http.get('/getAllProductCategory'); […]