草庐IT

function-parameter

全部标签

javascript - AngularJS: "TypeError: undefined is not a function"与 routeProvider

我正在尝试追踪AngularJS中的“TypeError:undefinedisnotafunction”错误。如果您有任何想法,甚至更好,关于如何调试此类内容的建议,我将不胜感激。请注意,这与我正在处理的代码非常相似,但并不完全相同(尽管它在运行时仍然有相同的错误)。追踪:TypeError:undefinedisnotafunctionatupdate(http://localhost:63342/Channels/vendor/angular-route.js:838:13)atScope.$broadcast(http://localhost:63342/Channels/ve

javascript - 类型错误 : undefined is not a function in Angular Resource

当尝试在AngularJS资源上轮询自定义方法copies时,我在angular.js:10033处收到以下错误:(方法copy工作得很好。)TypeError:undefinedisnotafunctionathttps://code.angularjs.org/1.3.0-beta.8/angular-resource.min.js:9:347atArray.forEach(native)atq(https://code.angularjs.org/1.3.0-beta.8/angular.min.js:7:280)atq.then.p.$resolved(https://code

javascript - 使用 AngularJS 时出现 ".then() is not a function"错误

这是我的JS:self.obj={}self.obj.accessErrors=function(data){varcerrorMessages=[];for(propindata){if(data.hasOwnProperty(prop)){if(data[prop]!=null&&data[prop].constructor==Object){self.obj.fetch[accessErrors](data[prop]);}else{cerrorMessages.push(data[prop]);}}}returncerrorMessages;};self.obj.fetch={

javascript - Angular : Update A Function In RealTime

我有一个Controller:$scope.timeAgoCreation=function(order){returnmoment(order.createdAt).fromNow();};在View中:{{timeAgoCreation(order)}}它返回正确的值:9分钟前。但是这个值不是实时更新的。我必须刷新页面。是否可以让它实时更新? 最佳答案 只需将此功能添加到Controller中(不要忘记注入(inject)$timeout服务):functionfireDigestEverySecond(){$timeout(f

javascript - Bluebird.JS Promise : new Promise(function (resolve, reject){}) vs Promise.try(function(){})

我什么时候应该使用哪个?以下是一样的吗?新的Promise()示例:functionmultiRejectExample(){returnnewPromise(function(resolve,reject){if(statement){console.log('statement1');reject(thrownewError('error'));}if(statement){console.log('statement2');reject(thrownewError('error'));}});}Promise.try()示例:functiontryExample(){return

javascript - 如何使用 Cloud Functions for Firebase 与 .onWrite 或 onchange 比较新旧值?

让我们采用以下数据结构:现在我想用Firebase函数刷新accessTokenFacebook。我测试了两个选项:onWrite和:onChangedonWrite对我来说看起来最好,但具有以下功能:exports.getFacebookAccessTokenOnchange=functions.database.ref('/users/{uid}/userAccountInfo/lastLogin').onWrite(event=>{constlastLogin=event.data;letdateObject=newDate();letcurrentDate=dateObject

javascript - jQuery控制台报错: $(this). effect is not a function

我已经盯着我的代码看了好几个小时,现在我想弄清楚为什么这个看似简单的jQuery游戏不起作用:title"test"test2011test$(document).ready(function(){$(".tNail").click(function(){$(this).effect("scale",{percent:200,direction:'both'},1000);});});我试过使用noConflict()无济于事。如果有人能阐明一些问题,我将不胜感激。谢谢。 最佳答案 啊,再看一遍,我觉得报错信息大

javascript - `new Function("在立即调用的函数中返回 this")()` 的目的是什么

我正在查看setImmediatepolyfill它包含在立即调用函数中,包含以下内容:(function(global,undefined){"usestrict";...}(newFunction("returnthis")()));我对最后一条语句的目的和传递给函数的参数感到困惑。这段代码既可以在浏览器中运行,也可以在Node.js上运行,这与它有什么关系吗?你能解释一下吗? 最佳答案 代码的编写使其可以访问全局范围,无需知道包含该范围的对象是什么。例如,在浏览器中,全局范围是window,但在其他容器中并非如此。通过使用Fu

javascript - Google Maps Uncaught TypeError : b. has is not a function

我们使用以下代码将GoogleMapsAPIV3包含在我们的内部系统中:脚本src="https://maps.googleapis.com/maps/api/js?key=&libraries=places,geometry"这在几个小时前(澳大利亚东部标准时间上午9点)之前一直有效,现在在控制台中返回的所有内容是:未捕获类型错误:b.has不是函数来自https://maps.googleapis.com/maps-api-v3/api/js/35/3/map.js有没有人遇到同样的问题?如果包含来自Google服务器的代码,我该如何解决? 最佳答案

javascript - 如何在单元测试中调用 $(document).ready(function() {})

我在单元测试中尝试调用document.ready(function(){})时遇到困难。假设我的javascript文件中有多个,其中一个在命名函数内调用,即functionmyFunction(){$(document).ready(function(){//...});}我如何在我的单元测试中实际调用它们以便我可以实际测试它们?我正在使用JsTestDriver对我的javascript进行单元测试。谢谢。 最佳答案 如果是单元测试,我猜你会在给定特定输入时检查函数输出?这是我的看法:您应该为调用document.ready的