草庐IT

Angular-Google-Map

全部标签

javascript - angular2 - 从父路由到子路由的传递值

我有一个名为home的路由,它有三个子路由、文档、邮件和垃圾。在主路由组件中,它有一个名为“user”的变量。我知道有几种方法可以在父组件和子组件之间传递信息突出显示here,但我应该如何在父/子路由之间传递信息。{path:'home',component:HomeComponent,children:[{path:'documents',component:DocumentsComponent},{path:'mail',component:MailComponent},{path:'trash',component:TrashComponent},]},服务import{Inje

javascript - 如何将自定义库事件(即 Google map 事件)转换为 RxJS 中的 Observable 流?

我想从Googlemap事件创建一个RxJS可观察流。我知道如何从native浏览器事件中执行此操作,如下所示:varresult=document.getElementById('result');varsource=Rx.Observable.fromEvent(document,'mousemove');varsubscription=source.subscribe(function(e){result.innerHTML=e.clientX+','+e.clientY;});mousemove是一个浏览器事件,这使我相信.fromEvent()将mousemove识别为硬编码

javascript - 在angular2中使用窗口对象但vscode "Cannot find name '窗口'“

我用VisualStudio代码编写了一个angular2应用程序。最近,我将VisualStudioCode更新到了1.10.2。但它已将window突出显示为有错误。当我检查它时,我发现它说:[ts]Cannotfindname'window'.我的代码如下:saveCustomIndex(customIndex:any,indexName:string){window.localStorage.setItem(indexName,JSON.stringify(customIndex));}截图我该如何处理?谢谢! 最佳答案 在

javascript - Angular2 setTimeout 返回 ZoneTask 而不是 "Number"

尝试在angular2中使用setTimeout,我想稍后清除超时。但是Angular2返回的是“ZoneTask”而不是数字constructor(){this.name='Angular2'this.timeoutId=setTimeout(()=>{console.log('hello');},2000);console.log("timeoutID---",this.timeoutId);//Output-ZoneTask{_zone:Zone,runCount:0,_zoneDelegates:Array[1],_state:"scheduled",type:"macroTa

javascript - 当 `ngModelChange` 保持值时,Angular ngModel 不会更新

我有一个文本字段表示为:field={text:"",valid:false},以及一个带有[(ngModel)]="field.text".我想让那个字段只接受一组定义的字符(对于这个问题,数字),并且(keypress)在移动设备上不起作用,所以我做了:(ngModelChange)="fieldChanged(字段)"该方法执行以下操作:fieldChanged(field){console.log(field.text);field.text=Array.from(field.text).filter((char:string)=>"0123456789".indexOf(ch

javascript - `new Array(5).map()` 是如何工作的?

这个问题在这里已经有了答案:JavaScript"newArray(n)"and"Array.prototype.map"weirdness(14个答案)WhydoesArray.apply(null,[args])actinconsistentlywhendealingwithsparsearrays?(2个答案)DifferencebetweenArray.apply(null,Array(x))andArray(x)(5个答案)关闭5年前。我最近发现映射一个未初始化的数组似乎并不像我预期的那样有效。使用此代码:functionhelloMap(value,index){retur

javascript - angular-ui-router 1.0.x : event. preventDefault & event.defaultPrevented 替代

我刚刚将$stateChangeStart替换为$transitions.onStart$rootScope.$on('$stateChangeStart',function(e,...){e.preventDefault();//othercodegoeshere...});到$transitions.onStart({},function(tras){//needacodeequivalenttoe.preventDefault//needacodetoidentifyevent.defaultPrevented//othercodegoeshere...//getparentst

javascript - i18next 模块的 Google Apps 脚本错误

我正在用ES6编写我的项目,目前面临i18next模块的问题。https://www.i18next.com/在我的本地系统上,当我导入i18nextimporti18nextfrom'i18next';并在我的源文件中使用它时,一切正常。然而,在我运行npmrungulp(它将所有源文件合并到一个javascript文件-main.js)并尝试将该代码上传到GoogleApps脚本(使用gappsupload),它因错误请求而失败。上传失败。错误。在网上查了一下发现这个错误是语法有问题,所以我尝试将main.js中的代码复制粘贴到googleapps脚本中,结果显示如下语法错误:In

javascript - 带有 Bootstrap 4 Grid 的 Angular Material 2

我正在使用Angular4并安装了AngularMaterial2,因为我喜欢组件的外观。所以现在我拥有所有组件并想要创建布局。我知道它有AngularFlex布局,但老实说我不太了解Flex,所以我在考虑使用Bootstrap的4Grid来整理布局。为什么我不应该将Bootstrap的网格与AngularMaterial2一起使用? 最佳答案 将bootstrapgrid与angularmaterial2一起使用是毫无意义的。Idon'tknowFlexthatwellsoIwasthinkingonusingBootstrap'

javascript - 如何从 Jasmine 测试 Angular 2/4 触发文档级事件

根据Angular测试文档,要从测试中触发事件,我们在调试元素上使用triggerEventHandler()方法。此方法采用事件名称和对象。现在,如果我们使用HostListener添加事件,这将起作用。例如:@HostListener('mousemove',['$event'])或添加一个document级别的事件,我们这样做是这样的@HostListener('document:mousemove',['$event']).在我当前的指令实现中,由于我无法嵌套HostListeners,我使用document.addEventListener添加document级事件到Host