草庐IT

function_that_can_throw

全部标签

javascript - 未捕获的对象错误 : can't inject ngAnimate

当我尝试像这样注入(inject)“ngAnimate”时,我无法实例化我的应用程序:varapp=angular.module('musicsa',['ngCookies','ngResource','ngSanitize','ui.router','firebase','ngAnimate'])我从angular.js第78行收到错误Uncaughtobject我使用Bower安装了ngAnimate。这是我的bower.json:{"name":"ang-changeorg","version":"0.0.0","dependencies":{"angular":"1.2.6",

javascript - karma : Can't find variable: exports

我写了一个可以同时用于后端和客户端的Node模块(exports||window).Bar=(function(){returnfunction(){....}})();现在我的karma测试使用PhantomJs并提示不存在的exports变量gulp.task('test',function(){varkarma=require('karma').server;karma.start({autoWatch:false,browsers:['PhantomJS'],coverageReporter:{type:'lcovonly'},frameworks:['jasmine'],fi

javascript - "bar"中 "var foo = function bar (){ ... }"的用途是什么?

在DouglasCrockford的书中,他将递归函数写为:varwalk_the_DOM=functionwalk(node,func){func(node);node=node.firstChild;while(node){walk(node,func);node=node.nextSibling;}}我从未见过定义为varfoo=functionbar(){...}的函数-我总是看到声明的右侧是匿名的:varfoo=function(){...}声明右侧的名称walk的唯一目的是缩短walk_the_DOM的调用吗?它们似乎成为相同功能的不同名称。也许我误解了这段代码的工作原理。

javascript - 基本 d3 : why can you select things that don't exist yet?

我一直在学习d3,我对选择有点困惑。考虑以下示例:http://bl.ocks.org/mbostock/1021841具体来说,让我们看一下这一行:varnode=svg.selectAll(".node").data(nodes).enter().append("circle").attr("class","node").attr("cx",function(d){returnd.x;}).attr("cy",function(d){returnd.y;}).attr("r",8).style("fill",function(d,i){returnfill(i&3);}).styl

javascript - arguments 属性可以通过 this.some_function.arguments 访问吗?其实我无法解释?

我在读一本JavaScript书,我在读如何通过原型(prototype)扩展JavaScript数组的数组功能,然后我来到这个我无法理解的例子,也没有对它进行深入的解释,我不是能够理解:Array.prototype.some_function=function(){varargs=this.some_function.arguments;//1varargs_length=this.some_function.arguments.length;//2...}//some_function在这里我能够访问参数,但我不知道这是如何工作的,意思是this指的是我们调用此方法的对象(在此上

javascript - 类型错误 : mongodb property insertmany is not a function

db.col.insertMany([{"_id":"tt0084726","title":"StarTrekII:TheWrathofKhan","year":1982,"type":"movie"},{"_id":"tt0796366","title":"StarTrek","year":2009,"type":"movie"},{"_id":"tt0084726","title":"StarTrekII:TheWrathofKhan","year":1982,"type":"movie"}]);OS:LinuxMint17.3RosaMongoDB:dbversionv2.6.1

javascript - Cloud Functions for Firebase 在 CORS 预检请求上触发功能

我有一个云功能,可以验证来自客户端表单提交的输入。我正在为Firebase使用CloudFunctionshttpstriggers与corsexpressmiddleware.Firebase函数constfunctions=require('firebase-functions');constexpress=require('express');constcors=require('cors')({origin:true});constvalidateImageForm=require('./library/validate-image-form');exports.apiVali

javascript - 行为主题 : next is not a function

我正在尝试在同级组件之间共享数据并通过共享服务执行此操作。当第一个组件加载时,它从我的API中检索服务器列表,并用所有检索到的服务器填充一个选择框。现在我想在用户选择新服务器时通知我的其他组件,以便我可以显示它的详细信息。这是我的服务:@Injectable()exportclassDashboardService{servers:Server[]=[];selectedServer=newBehaviorSubject(null);setServers(servers:Server[]){this.servers=servers;}}带有选择框的组件:@Component({sele

javascript - 实用程序.crypto.lib。 randomBytes 不是函数 : aws cognito js throws error on authentication

我收到以下错误:TypeError:__WEBPACK_IMPORTED_MODULE_0_aws_sdk_global__.util.crypto.lib.randomBytesisnotafunction当我尝试使用我编写的以下代码对用户进行身份验证时:import{CognitoUserPool,CognitoUserAttribute,CognitoUser,AuthenticationDetails}from'amazon-cognito-identity-js';letauthenticationDetails=newAuthenticationDetails({Usern

javascript - JEST 错误 TypeError : specificMockImpl. apply is not a function

尝试使用来自api的回调来模拟其中一个函数并得到错误TypeError:specificMockImpl.applyisnotafunctionimport{IEnvironmentMap,load}from'dotenv-extended';import{getTokensWithAuthCode,sdk}from'../src/connection-manager';describe('getTokensWithAuthCodefunctionTests',()=>{jest.useFakeTimers();letboxConfig:IEnvironmentMap;beforeAl