草庐IT

direct_to_template

全部标签

javascript - Webpack 工作加载器 : How to make it work as a dependency?

我有我的index.html导入依赖项。myModule/app.jsvarWebWorker=require('worker-loader!./worker');window.WebWorker=newWebWorker();worker存在于node_modules/myModule/worker.js当我运行“webpack”时,它可以正常工作,因为它们位于同一个文件夹中。如果我更改路径中的任何内容,webpack将不会根据需要获取webworker代码。将此模块用作依赖项时会出现问题,因为我需要将worker.js放在与index.html相同的路径中。替代方法是使用Blob并

javascript - meteor JS : How to stub validated method in unit test

我正在使用经过验证的方法(mdg:validated-method)和LoggedInMixin(tunifight:loggedin-mixin)。现在我的单元测试出现了问题,因为它们因notLogged错误而失败,因为在单元测试中当然没有登录用户。我怎么必须stub呢?方法constresetEdit=newValidatedMethod({name:'reset',mixins:[LoggedInMixin],checkLoggedInError:{error:'notLogged'},//单元测试describe('resetEdit',()=>{it('shouldreset

javascript - jQuery 数据表 : iDisplayLength set to -1 to show all rows

我使用jQueryDatatables并希望通过来自服务器的ajax收听包含我所有条目的表格。一切都很完美。我的意思是,我得到数据并可以在表格中显示它们。我只有一个问题。我想一次显示所有行/条目。我在谷歌上搜索过,所有人都说,我只需要将iDisplayLength设置为-1。但如果我这样做,我只有1个条目/行(显示总共50个条目中的1个中的1个)。知道我做错了什么吗?这是我初始化表的代码:varoTable=$("#roles").dataTable({"bServerSide":true,"sAjaxSource":"/data","iDisplayLength":-1,"aoSea

javascript - rails + Chartkick : How to change the date format of the tooltip?

我正在以这种方式生成图表(使用GoogleChart):"Solditems",data:@items.group(:created_at).count}],:library=>{hAxis:{title:"Period"},vAxis:{title:"AmountsinUDS"},title:"HistoryOfSales"}%>图表生成得很好,但有一件事我想改变——工具提示看起来像这样:工具提示中的信息是正确的,但我不想显示Oct19,2014,2:00:00AM我只想显示Oct19,2014。有没有办法用Chartkick做到这一点?非常感谢您的宝贵时间。

javascript - AngularJS : Should service's boolean method return promise that resolves to true/false, 或者被解决/拒绝?

promise的使用模式仍然让我感到困惑。例如,在Angular应用程序中,我有一个服务usersService,方法是emailExists(email)。显然,它向服务器请求检查给定的电子邮件是否已经存在。让方法emailExists(email)返回在正常操作中解析为true或false的promise对我来说感觉很自然.如果只是我们有一些意外的错误(比如,服务器返回500:内部服务器错误,那么promise应该被拒绝,但在正常操作中,它被解析为相应的bool值。然而,当我开始实现我的异步验证器指令(通过$asyncValidators)时,我看到它想要解决/拒绝promise。

javascript - ngSmoothScroll Angular Directive(指令)不起作用

我正在使用以下指令https://github.com/d-oliveros/ngSmoothScroll使这个项目中的东西平滑地滚动到选定的元素。这是我的代码:......这就是包含脚本的地方(~/angular-smooth-scroll.min.js)在我的app.js文件中我有:angular.module('sccateringApp',['ngAnimate','ngAria','ngCookies','ngMessages','ngResource','ngRoute','ngSanitize','ngTouch','ui.materialize','smoothScro

javascript - MEANJS 样板文件 : where to include custom javascript files?

我开始使用MeanJS样板文件(refwebsite)并想知道推荐的地方在哪里包含公共(public)自定义javascript、jQuery文件(例如FacebookSDK、jQuery动画,...)。我假设它将位于公用文件夹中的某个位置。默认结构如下:它应该放在modules还是lib文件夹中?您能否就每个文件夹的功能提供更多指导?有什么指导方针吗? 最佳答案 这是一篇关于Angular应用程序文件夹结构的精彩文章:https://scotch.io/tutorials/angularjs-best-practices-dire

javascript - 将自定义指令添加到已有 Angular Directive(指令)的现有输入 [ng-model/ng-required]

我想使用一个用ng-model和ng-required修饰的标准输入控件,然后添加我自己的自定义属性指令以提供uib-typeahead控件的功能。我使用此链接使我的指令部分起作用。AdddirectivesfromdirectiveinAngularJSPLUNKR-TheVersion2ofthedirectivedoesnotworkcorrectlywithng-model我的指令确实添加了预输入功能并且效果很好,但它没有在选择项目后将模型绑定(bind)到控件上。我有两个版本的指令。版本1:是一个元素样式指令,我已经成功使用它一段时间了,但是当我不想对输入元素有更多控制时,它

javascript - react native + 终极版 : Why does Switch immediately turns back to false after being switched to true?

在iOSReactNative+Redux中,我使用了以下Switch组件(https://facebook.github.io/react-native/docs/switch.html)。它首先设置为关闭,但是当打开时,它会立即自行关闭。可能是什么问题?这是我的设置:触发的Action是:_handleSwitch(value){this.props.actions.triggerSwitch(value)}Action是:exportfunctiontriggerSwitch(value){return{type:TRIGGER_SWITCH,currentValue:value

javascript - typescript 键盘事件 : argument of type 'Event' is not assignable to parameter of type 'KeyboardEvent'

即使代码运行完美,我也会出现以下错误:"TS2345:Argumentoftype'Event'isnotassignabletoparameteroftype'KeyboardEvent'.Property'altKey'ismissingintype'Event'."//InaClasspubliclistenTo=(window:Window)=>{['keydown','keyup'].forEach(eventName=>{window.addEventListener(eventName,e=>{this.handleEvent(e);//{const{key}=event