草庐IT

this-is-a-collection

全部标签

javascript - Angular 2 自定义验证器 : check if the input value is an integer?

在Angular2项目中,我需要验证一些输入。如何轻松检查输入值是否为整数?我尝试使用Number(control.value)为空字段返回0-不好。或parseInt(control.value,10)不考虑空格:如果我有类似的东西:1space0,24=1,024它返回1-它通过了验证器没有错误。Lodash函数如:_.isInteger(control.value)或_.isNumeric(control.value)//每次都返回false-这是预期的,因为输入值是字符串而不是数字。像这样组合方法会创建一个包含许多if/else语句的困惑函数,即便如此,我也不确定我是否得到了所

javascript - Google 日历 API 和 Node js - "googleAuth is not a constructor"问题

我正在尝试在Node上设置Google日历API,使用出现的Node.js快速入门here完成前3个步骤并运行我的quickstart.js以检查它是否有效(我从快速入门复制并粘贴)后,我收到以下错误:“类型错误:googlAuth不是构造函数”它指的是这行代码:varauth=newgoogleAuth();googleAuth是这样声明的:vargoogleAuth=require('google-auth-library');我在网上找不到任何解决方案。完整代码在上面第三步的链接中。提前致谢,阿萨夫。 最佳答案 版本已经改变,

javascript - Google Maps API 加载失败 ("' google' is undefined") in IE8

当我加载http://maps.google.com/maps/api/js?sensor=false时在脚本标签中,我在Chrome、Safari、Firefox和IE9中一切正常。但是,当我在兼容模式中查看IE9(或者,有人告诉我,在IE8中)时,map不会加载并且“'google'未定义”"记录在控制台中。这是相关代码,触发错误的行用注释标识:TestMapvarlat=37.763154;varlon=-122.457941;varinitialZoom=17;varmapTypeId='CustomMap';varmapStyle=[{featureType:"landsca

javascript - 在匿名内部使用 'this',IDE : potentially invalid usage

就最佳实践而言,下一个功能(实际有效)是否不好?IDE警告我'Potentiallyinvalidusageof'this'.ChecksforJavascript'this'tobeinthesameclosureoroutercontent.$(document).on('change','#select-all',function(){if(this.checked){$(this).closest('table').find('input[name="row-id"]').each(function(){this.checked=true;//Here})}else{$(thi

javascript - jQuery this.remove() -vs.- $ ('#id' .remove() 在 Internet Explorer (IE 9+)

为什么this.remove()在IE9+中不起作用?$('#nextButton1').on('click',function(){this.remove();//worksinallbrowsersbutIE9+});$('#nextButton2').on('click',function(){$('#nextButton2').remove();//worksinallbrowsers});JSFiddleliveversion 最佳答案 那是因为您正在使用并非所有浏览器都支持的ChildNode.remove()方法。th

javascript - Uncaught ReferenceError : angular is not defined (Using testem)

在2个文件的第1行发现错误:-controllers.js-应用程序js下面连同html一起附上。当我启动本地服务器时出现该应用程序,但我无法登录或在输入我的详细信息后单击注册按钮进行注册。是404错误吗?我也尝试将这两行添加到index.html文件中(我认为是我没有定义的一些项目)但是没有用。index.html文件****Backcontrollers.js文件(第一行错误)angular.module('bucketList.controllers',[]).controller('SignInCtrl',['$scope','$rootScope','$firebaseAut

javascript - Array.from 类型错误 : 0 is not a function

尝试将Array.from传递给Array.prototype.map时出现奇怪的错误。letfn=Array.from.bind(Array);//[Function:boundfrom]fn('test')//['t','e','s','t']['test'].map(s=>fn(s))//[['t','e','s','t']]['test'].map(fn)//TypeError:0isnotafunction完整错误:TypeError:0isnotafunctionatFunction.from(native)atArray.map(native)atrepl:1:10atR

javascript - 异步/等待分配给对象键 : is it concurrent?

我知道这样做:constresultA=awaita()constresultB=awaitb()//codehere有效a().then(resultA=>{b().then(resultB=>{//codehere})})基本上,a()运行然后b()运行。我嵌套它们以表明resultA和resultB都在我们的范围内;但是这两个功能都没有同时运行。但是这个呢:constobj={result1:awaita(),result2:awaitb()}a()和b()是否同时运行?供引用:constasyncFunc=async(func)=>awaitfunc.call()constre

javascript - 为什么将字符串作为 "this"传递会导致这种奇怪现象?

我试图理解为什么javascript会做一些(对我来说)意想不到的事情。这里有一些代码,纯粹是为了举例。换句话说,我实际上并不想扩展String(我实际上绑定(bind)到函数和东西)。所以这是没有库的纯JavaScript。vars='blah';String.prototype.foo=function(){console.log('this===s:',this===s);console.log('this==s:',this==s);console.log('typeofthis:',typeofthis);console.log('typeofs:',typeofs);con

javascript - 主干错误 : Uncaught TypeError: Object function (){ parent. apply(this, arguments); } 没有方法 'on'

知道为什么我在调用collection.fetch时会收到此错误吗?在这段代码中抛出:这是触发错误的代码:$(document).ready->SearchResult=Backbone.Model.extendSearchResults=Backbone.Collection.extendurl:"/backbone/search"model:SearchResultparse:(response)->console.logresponsenewSearchResultid:response.idtitle:response.titlesearchResults=newSearchR