草庐IT

load_functions

全部标签

javascript - Angular UI 路由器 : URL changed but view isn't loaded

我正在使用嵌套View开发我的UI-Router应用程序。我这样定义了一些状态:$stateProvider.state('parent',{url:"/parent",views:{'area1':{templateUrl:'parentView.html'},'area2':...//someotherareas+template}}).state('parent.child1',{url:"/child1",views:{'area1':{templateUrl:'child1View.html'},'area2':...//stillsomeotherareas,notchan

javascript - 卡斯珀JS : Why does my url change to about:blank when my page is loaded?

我是PhantomJS/CasperJS的初学者。我只想启动一个session并验证它是否正常。这是我的代码:varcasper=require('casper').create({verbose:true,logLevel:'debug',pageSettings:{loadImages:false,loadPlugins:false,userAgent:'Mozilla/5.0(WindowsNT10.0;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/39.0.2171.71Safari/537.36Edge/12.0'}});ca

javascript - "Partial Function Application"在 Javascript 上下文中是用词不当吗?

我和我的一个friend正在讨论Javascript中的柯里化(Currying)和偏函数应用,关于两者是否可以实现,我们得出了截然不同的结论。我想到了Function.prototype.curry的实现,这是我们讨论的基础:Function.prototype.curry=function(){if(!arguments.length)returnthis;varargs=Array.prototype.slice.apply(arguments);varmmm_curry=this,args;returnfunction(){varinner_args=Array.prototy

javascript - 我是否正确理解了这个 Function.prototype.call() 代码?

代码:varcontent=Array.prototype.map.call(document.getElementsByTagName("p"),function(e){returne.innerHTML;});来自p.367ofJavaScript:权威指南,第6版。这是我认为这段代码中发生的事情。变量content正在分配.map()的结果调用NodeListdocument.getElementsByTagName("p")返回的段落标签数量..map()方法是从Array.prototype访问的,及其this值设置为段落标记NodeList使用.call().自.map()

javascript - Angular Testing : Spy a function that was executed on the initialize of a controller

我一直在尝试监视在Controller初始化时执行的函数,但测试总是失败。我一直在尝试执行$scope.$digest()但它不起作用,但是在控制台中,我看到该函数已被调用。我想不通,有人可以向我解释为什么它不起作用吗?代码笔示例:http://codepen.io/gpincheiraa/pen/KzZNbyControllerfunctionController($stateParams,$scope){$scope.requestAuthorization=requestAuthorization;if($stateParams.requestAuthorization===tr

javascript - .then(functionReference) 和 .then(function(value){return functionReference(value)}) 之间有区别吗?

给定一个用于处理Promise值的命名函数functionhandlePromise(data){//dostuffwith`data`returndata}a)将命名函数handlePromise作为对.then()的引用传递promise.then(handlePromise)b)使用匿名函数或命名函数作为.then()的参数,并以Promise值作为参数返回命名函数handlePromise在传递给.then()的匿名或命名函数的主体内promise.then(function/*[functionName]*/(data){returnhandlePromise(data)})

javascript - Chrome 扩展 : how to detect that content script is already loaded into a tab?

我的后台脚本中有以下代码:chrome.tabs.onUpdated.addListener(function(tabId,changeinfo,tab){if(changeinfo.status!=='complete')return;if(!matchesUrlFilters(tab.url))return;chrome.tabs.executeScript(tabId,{file:"jquery-1.7.1.min.js"},function(){chrome.tabs.executeScript(tabId,{file:"enhance.js"});});});但是,在某些情况

javascript - JS 继承 : calling the parent's function from within the child's function

JS对象模型肯定有不明白的地方。来自这些资源:PrototypesBasicOOPinJS-InheritanceObject.create()我收集了我认为或认为是对象模型的准确心理表征。在这里:所有对象都有一个属性,文档将其称为[[Prototype]]。[[Prototype]]可以被认为是对对象父对象的引用。更准确地说:Thereferencetothe[parent's]prototypeobjectiscopiedtotheinternal[[Prototype]]propertyofthenewinstance.(source1)您可以使用Object.getProtot

javascript - 类型错误 : is not a function typescript class

我在typescript类中遇到以下错误,无法理解原因。我所做的只是尝试调用传递token的辅助函数。错误:posterror:TypeError:this.storeTokenisnotafunction(…)类:/***AuthenticationService:**Containsthehttprequestlogictoauthenticatethe*user.*/import{Injectable}from'@angular/core';import{Http,Response,Headers,RequestOptions}from'@angular/http';import

javascript - 如何在 Javascript 中实现 "function timeout"- 而不仅仅是 'setTimeout'

如何实现timeout在Javascript中,不是window.timeout而是类似sessiontimeout或sockettimeout-基本上-“functiontimeout"Aspecifiedperiodoftimethatwillbeallowedtoelapseinasystembeforeaspecifiedeventistotakeplace,unlessanotherspecifiedeventoccursfirst;ineithercase,theperiodisterminatedwheneithereventtakesplace.具体来说,我想要一个ja