草庐IT

angular-http-interceptors

全部标签

javascript - 写入 Firebase 时将 Angular ng-model 转换为整数

我正在使用AngularFire获取输入并将它们保存到我的Firebase数据库中。目前,我有一个用于输入服务价格的输入,就像这样(我使用的输入类型是“文本”而不​​是“数字”,因为我不希望它在旧浏览器中引起问题):但是,当我在提交表单时(使用更新函数)将其写入我的Firebase时,它​​会将值$scope.priceMonthly写入字符串而不是整数。将此值写为整数而不是字符串的最佳方法是什么? 最佳答案 type="number"怎么样,比如:因为你想让用户只写数字。$scope.myText应该是这种情况下的数字。作为旁注:

javascript - Breeze 使用 Angular $http 拦截器

我使用Angular$http拦截器来检查ajax请求是否返回401(未通过身份验证)。如果响应为401,则原始请求排队,显示登录表单,登录成功后,它会重试排队的请求。这已经适用于$http,Angular拦截器的来源是:define('common.service.security.interceptor',['angular'],function(){'usestrict';angular.module('common.service.security.interceptor',['common.service.security.retryQueue']).factory('sec

javascript - Angular.js promise 在使用 karma 进行单元测试服务时不会解析

我正在尝试对Angular.js服务进行单元测试,并且需要对从模拟服务(使用Jasmine)返回的promise设置期望。我正在使用karma单元测试框架。相关代码片段如下://Ican'tfigureouthowtodotheequivalentofa$scope.$digesthere.varloginStatusPromise=FacebookService.getFacebookToken();loginStatusPromise.then(function(token){expect(false).toBeTruthy();//Ifthistestpasses,thereis

javascript - angular-google-maps 现在在开始时隐藏时可以正确显示

本地图开始使用ng-show/ng-hide隐藏时,一旦可见就无法正确显示。标准map也有同样的问题,只有我们可以向它发送调整大小,因为我们可以访问map对象。这是一个以隐藏map开始的示例。该按钮切换map的可见性。.angular-google-map-container{width:100%;height:100px;}.mymap{width:100%;height:100px;}ToogleMapvarapp=angular.module("app",["google-maps"]);app.controller("myCtrl",function($scope,$timeo

javascript - angular.js ui + bootstrap typeahead + 异步调用

我将typeahead与angular.js指令一起使用,但我填充自动完成的函数进行了异步调用,我无法返回它来填充自动完成。无论如何让它与这个异步调用一起工作? 最佳答案 我可以假设您正在使用Bootstrap2.x的typeahead吗?如果是这样,在文档中,typeahead()选项的source字段的描述是这样的:Thedatasourcetoqueryagainst.Maybeanarrayofstringsorafunction.Thefunctionispassedtwoarguments,thequeryvaluein

javascript - express 和 http 之间的技术区别是什么,并就此进行连接

varexpress=require("express"),app=express(),http=require("http").createServer(app)我经常看到这些被放在依赖项上。从我的理解来看,http托管前端html?并且express拥有服务器端的nodejs逻辑?connect是express的基础层,那么它也是一个服务器端模块吗?如果不是这样,为什么人们不这样做express().listen(8080)代替require("http").createServer(express()).listen(8080) 最佳答案

javascript - gMarker.key 未定义,它是必需的!! Angular 和谷歌地图应用程序中的错误

我有一个应用程序,我试图在Angular应用程序上实现谷歌地图,以在用户选择地点时显示坐标在map上的位置。当我尝试加载此应用程序时出现错误。HTML工作正常,但谷歌地图没有显示在我的应用程序上。可以在以下位置查看:http://creative.coventry.ac.uk/~4078078/Map/gMarker.keyundefinedanditisREQUIRED!!代码如下:HTML:zoom我已经提供了头文件,因为之前的文件有错误。我该如何解决这个错误? 最佳答案 我相信您在marker指令中缺少idkey参数。这是1.

javascript - 如何在 Angular 中过滤不相等的嵌套对象?

可能缺少一些简单的语法,但我似乎无法使用不相等的过滤器:我可以过滤器:{property:{text:'yes'}},但不是过滤器:{property:{text:'!yes'}},它确实适用于非嵌套对象。HTML:{{attr.property.text}}JS:$scope.attributes=[{property:{text:'yes'}},{property:{text:'no'}},];Plunkr链接:http://plnkr.co/edit/2mTcQijmfnqAM5vUtKsK?p=preview 最佳答案 你可

javascript - 使用 $http 在 AngularJS 中调用 cURL

我是Angular的新手,我想在我的header中传递一个访问token,但我似乎做对了。我有一个工作正常的curl请求,我正试图让它以Angular工作:curlhttp://localhost:3000/api/v1/users-IH"Authorization:Tokenapi_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxx"无法正常工作的Angular$http调用$http.get('http://localhost:3000/api/v1/users',{headers:{'api_key':'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'}}

javascript - 从 http header 响应中获取日期

好的,我可以使用访问HTTPajax响应headerxhr.getAllResponseHeaders();但它似乎没有得到日期,尽管它在那里:[Chrome]**ResponseHeader**Access-Control-Allow-Origin:*Cache-Control:no-cacheContent-Length:8092Content-Type:application/json;charset=utf-8**Date:Thu,15Jan201516:30:13GMT**Expires:-1Pragma:no-cacheServer:Microsoft-IIS/8.0Tot