草庐IT

has-scope

全部标签

javascript - $scope.$watch in Angular 在 Ionic/Cordova 中不起作用

我正在使用IonicFramework构建应用程序我现在想为此创建一些开关(基本上是花哨的复选框)。当有人按下开关时,我想将其发送到服务器,因此我首先trycatch开关更改事件。在基本的Angular安装中,我在html()和$watch中使用一个简单的复选框进行了尝试。在我的Controller中像这样:$scope.$watch('theswitch',function(){console.log('theswitchchanged');if($scope.boel){console.log('theswitchisTRUE');}else{console.log('theswi

javascript - 相当于 Lodash _.get 和 _.has 的下划线

我正在尝试为Lodash_.get和_.has搜索等效的Underscore,它能够直接访问嵌套对象的存在和值值而不需要检查其parent的存在。但是,在我看来,下划线_.get和_.has只能检查第一级的值。varobject={'a':{'b':2}};_.has(object,'a.b');//lodashshowstrue_.has(object,'a.b');//underscoreshowsfalse 最佳答案 据我所知,undercore不执行深度搜索,因此您必须满足于浅层has和get(或更改为lodash).你也可

javascript - $.递延 : How to detect when every promise has been executed

我有许多异步任务需要完成,所以我使用了promises。我需要检测每个promise何时执行(解决和拒绝)。在那之前我不能继续执行。我正在使用这样的东西:$.when(promise1,promise2,...).always();但是这段代码是错误的,因为when方法有惰性求值,一旦其中一个promise失败它就会返回。因此,always回调也会在其中一个promise失败时立即运行。我在考虑编写一个解决方法,但这个用例太常见了,也许有人已经这样做了,或者甚至有一种方法可以只使用jQuery来做到这一点(如果没有,最好添加一个Promise.whenNonLazy或将来的Promis

javascript - QuotaExceededError (DOM Exception 22) : The quota has been exceeded on Safari in incognito

当我处于隐身模式时,我在Safari上收到QuotaExceededError(DOMException22):Thequotahasbeenexceeded.。我经历过类似的问题:QuotaExceededError:Domexception22:Anattemptwasmadetoaddsomethingtostoragethatexceededthequota但是他们谈论setItem,我在其他地方得到了这个错误。我在这一行收到此错误:localStorage['gallery.extensions']=JSON.stringify({});或localStorage['asdf

javascript-未捕获的语法错误 : Identifier * has already been declared

console.log(a)//output:ƒa(){}vara=1;functiona(){};vara=10;console.log(a)//output:10====================vara=1;if(true){functiona(){};vara=10;}console.log(a)//thiscodethrowsUncaughtSyntaxError:Identifier'a'hasalreadybeendeclared除了ifblock之外,上面的代码片段都是相同的。为什么后者在javascript中允许在同一范围内使用vardelcare相同变量两次时

javascript - "setting a property that has only a getter"- Firefox 的 javascript 错误

直到最近,我一直在使用Safari4来测试和调试我当前的jQuery插件。我在Firefox中试用了我的代码,它开始提示JQuery-Framework中的某些内容:“设置一个只有getter的属性”。我试图找出哪一行导致Firefox提示,发现这发生在此处**$.fn.util.create_$dom=function(opt){var$dom={};$.each(opt.dom,function(name,val){console.log(name);var$elm=$('');$.each(opt.dom[name],function(_name,_val){if(_name==

javascript - 未捕获的类型错误 : Object [object Object] has no method 'apply'

我在创建的新网站上收到此UncaughtTypeError,但我无法找出导致该错误的原因。我在下面的链接中重现了这个问题,如果您查看浏览器的JS控制台,您会看到发生了错误,但没有其他任何反应。http://jsfiddle.net/EbR6D/2/代码:$('.newsitem').hover($(this).children('.text').animate({height:'34px'}),$(this).children('.text').animate({height:'0px'}));​ 最佳答案 确保将它们包装在异步回调

十分钟 Javascript : What is going on in this example code illustrating lazy scoping?

我一直在重读SpencerTipping的优秀作品JavascriptinTenMinutes在这个使用惰性作用域创建语法宏的示例中,我终究无法弄清楚发生了什么:varf=function(){return$0+$1};varg=eval(f.toString().replace(/\$(\d+)/g,function(_,digits){return'arguments['+digits+']'}));g(5,6);//=>11(exceptonIE)特别是,$0和$1正在被一个函数定义取代——那个函数是如何被计算的?(大概是通过eval(),但我没有看到)。函数中单个下划线参数的用

javascript - 如何在 Angular 2 中的无效字段上显示 'has-error' 类

给定:Email还有我的自定义[fieldValidity]指令:import{Directive,ElementRef,Input}from'angular2/core';import{NgControlName}from'angular2/common';@Directive({selector:'[fieldValidity]'})exportclassFieldValidityDirective{privateel:HTMLElement;@Input('fieldValidity')field:NgControlName;constructor(el:ElementRef){

javascript - redux 的 dispatch() 中的 [[Scopes]] 是什么

我正在使用redux和react。这使得dispatch可以作为组件中的Prop使用。因此,当我console.log(this.props)时,我在调度键下的日志中看到以下对象。[[Scopes]]:Scopes[5]0:Closure1:Closure2:Closure(createThunkMiddleware)3:Closure4:Global谁能解释一下这是什么? 最佳答案 [[Scopes]]是Chrome开发者工具在内部添加和使用的私有(private)属性,在C++中,hereinthesource.它显示函数范围内