草庐IT

how-debug-service

全部标签

javascript - EmberJS : How to render a template on select change

我是ember的新手,正在尝试弄清楚如何在选择控件更改时呈现模板。代码:App.LocationTypeController=Ember.ArrayController.extend({selectedLocationType:null,locationTypeChanged:function(){//Rendertemplate}.observes('selectedLocationType')});{{viewEmber.SelectcontentBinding="model"selectionBinding="selectedLocationType"optionValuePat

javascript - 了解 Javascript : how it works, 中的 “undefined” 如何安全地检查它以及是否可以重新分配

我一直在阅读JavaScript中的undefined,现在我不确定我的理解是否正确。关于如何检查undefined有很多讨论,但不知何故我找不到任何提及对我来说似乎是理解undefined实际工作方式的基础的东西(undefined是宿主对象的属性)。这就是这个问题的原因,我需要确认我理解的是正确的,如果我错了,我希望得到澄清。好的,首先,undefined是宿主对象(浏览器中的window)的属性,因此使用它是完全合法的:window.undefined此属性的值是"undefined"类型。这是与Object、String、Number和Null一起的JavaScript类型之一

javascript - 表达 js : How to download a file using POST request

当我使用GET时,一切正常。但是,我很难使用POST来达到同样的效果。这是我试过的代码:1.app.post("/download",function(req,res){res.download("./path");});2.app.post("/download",function(req,res){res.attachment("./path");res.send("ok");});3.app.post("/download",function(req,res){res.sendFile("./path");});它们都不起作用。执行此操作的正确方法是什么?编辑:我通过HTML表单

javascript - Angular.js + karma + Jasmine : Unknown provider for service

我正在为以下Angular.js服务编写测试:varmodule=angular.module('wp',['aws','lodash','jquery','moment','wp.model']);/***Wordpressservice.*/module.service('wpService',function(_,$http,$q,$aws,Post){varself=this;/***HTTPrequest.*/this.http=function(config){var$config=_.clone(config);if($config.user&&$config.passw

javascript - 未捕获( promise )DOMException : Subscription failed - no active Service Worker

我正在尝试订阅用户,但这是我第一次遇到的错误。第二次,它正在工作,因为用户已经处于事件状态这是我的代码:if('serviceWorker'innavigator){console.log('ServiceWorkerissupported');navigator.serviceWorker.register('sw.js').then(function(reg){console.log(':^)',reg);reg.pushManager.subscribe({userVisibleOnly:true}).then(function(sub){console.log('endpoin

javascript - 解构嵌套对象 : How to get parent and its children values?

下面的函数接收一个对象,该对象具有属性current,它也是一个对象,并且它具有selectionStart和selectionEnd属性。在这里,嵌套解构按预期使用Start和End变量工作,但我还需要current的值。functionsomeFunction({current:{selectionStart:Start,selectionEnd:End}}){//dosomethingwithcurrent,Start,andEnd}我如何使用解构得到它? 最佳答案 第一个解构只创建Start和End变量。如果要将curren

javascript - 微软表面 : How do I allow JavaScript touch/drag events to work without being intercepted by the browser?

我的网站上有一张GoogleMapsmap,但当它与MicrosoftSurface平板电脑一起使用时,“平移”手势会被浏览器拦截——它会尝试转到下一个浏览器窗口。如何允许浏览器忽略平移(拖动事件)以使map正常运行?转到maps.google.com,map完全可以拖动,因此Google必须采用一种解决方法。 最佳答案 根据MS的“指针和手势事件”指南(此处:http://msdn.microsoft.com/en-us/library/ie/hh673557%28v=vs.85%29.aspx#Panning_and_zoomi

javascript - 在 TypeScript 中使用箭头函数 : how to make them class methods?

我的编程经验相当丰富,但对TypeScript还很陌生。尝试将它与jQuery一起使用并立即遇到回调的“this”问题(例如$(document).ready。使用$.proxy()是一种方法,但使用TypeScript的箭头(lambda)函数似乎要好得多。但我只看到它们用作表达式——也就是说,整个函数都是内联定义的。我希望能够设置可以作为我的类的方法调用的箭头函数,例如(伪代码):classSomething{constructor(){$('navli').click(this.menuClick);}privatemenuClick(andthiswouldbeanarrowf

javascript - Aurelia.js : How do I animate an element when bound value changes?

我正在使用Aurelia.js对于我的用户界面。假设我有以下View标记:${item.name}${item.value}绑定(bind)到模型“项目”。当模型中的一个值发生变化时,我想为显示更改值的单元格设置动画。我怎样才能做到这一点? 最佳答案 这可以用Aurelia来完成customattributes特征。创建一个新的javascript文件来描述属性(我将属性命名为“animateonchange”):import{inject,customAttribute}from'aurelia-framework';import

Javascript : how to insert tags around a text selection?

我想创建一个小的WYSIWYGHTML文本编辑器,带有一个内容可编辑的div。为此,我使用window.getSelection()检索所选文本,当我单击按钮(粗体按钮)时,我执行一个函数以在所选文本周围添加粗体标记。但我对添加粗体标记的javascript代码(没有JQuery)一无所知。这里是我的代码:functionadd_tags(tags){container_contenteditable=document.getElementById("container_contenteditable");//Retrievetheselectedtext:sel=window.get