草庐IT

Nginx的URL Rewrite基本指令

全部标签

javascript - 将 jquery 插件转换为指令 Angular

我正在尝试将jQuery插件转换为指令。这是图书馆:Github.在文档中有一个选项:$(document).ready(function(){$("#datepicker").datepicker();$("#datepickerbtn").click(function(event){event.preventDefault();$("#datepicker").focus();})});我创建的指令:app.directive('dateP',function(){return{restrict:'A',require:'ngModel',link:function(scope,e

javascript - 基本 d3 : why can you select things that don't exist yet?

我一直在学习d3,我对选择有点困惑。考虑以下示例:http://bl.ocks.org/mbostock/1021841具体来说,让我们看一下这一行:varnode=svg.selectAll(".node").data(nodes).enter().append("circle").attr("class","node").attr("cx",function(d){returnd.x;}).attr("cy",function(d){returnd.y;}).attr("r",8).style("fill",function(d,i){returnfill(i&3);}).styl

javascript - Angular 2 中的指令执行顺序

如果我有一个带有点击处理程序和自定义属性指令的简单按钮,如下所示:Save在我的属性指令中,我使用hoSTListener装饰器来监听点击事件:@Directive({selector:`[attributedirective]`})exportclassAuditPusher{@Input('attributedirective')attributedirective:string='Missingmessage!';@HostListener('click',['$event'])pushAudit(){console.log('text:'+this.attributedirec

javascript - 如何在 Angular 2 中为脚本和样式指定基本 href?

我目前正在研究Angular2,我对如何将样式和脚本注入(inject)index.html有疑问通过AngularCLIbuild命令(我指的是在angular-cli.json中定义的脚本和样式)。问题是我在嵌套位置运行应用程序,例如:http://domain.com/my_app同时可以设置,注入(inject)的脚本和样式总是指向src到根域。即/而不是/my_app.当然,这会在尝试查看页面时导致404。我正在服务/dist直接。Nginx配置:server{server_namedomain.com;listen80;location/my_app{alias/srv/w

javascript - 单击时如何从 Controller 获取数据到指令

当我使用ng-clicked时,我试图从Controller将数据发送到指令链接函数,但是我未能将数据发送到指令,该指令在页面加载时调用第一次这是我的html代码click这是我的Controller.controller('myController',function($scope){$scope.clickMe=function(somedata){$scope.myVal=somedata;};});我的指令.directive('myDirective',function(){return{restrict:'E',scope:{myKey:'='},templateUrl:'

javascript - 使用指令将组件动态添加到子元素

尝试使用指令将组件动态放置到子元素。组件(作为模板):@Component({selector:'ps-tooltip',template:`{{content}}`})exportclassTooltipComponent{@Input()content:string;}指令:import{TooltipComponent}from'./tooltip.component';@Directive({selector:'[ps-tooltip]',})exportclassTooltipDirectiveimplementsAfterViewInit{@Input('ps-toolti

javascript - 如何在括号中设置 jslint ES6 指令?

我收到此错误:“需要一个标识符,却看到了‘const’”,我正在使用括号文本编辑器。我找到了这个答案:“您需要指定es6指令。请参阅JSLint帮助”。但我无法弄清楚如何在括号中指定es6指令。这是我的代码:constsingleQuotes='Singlequotes';constdoubleQuotes="Doublequotes";conststringLiterals=`Stringliterlas`;constresult=singleQuotes+doubleQuotes+stringLiterals;document.querySelector('.basic').inn

javascript - Angular Directive(指令) : Allow just numbers

这里是asampleangulardirectivetopreventtypingnon-numerickeys(StackOverflowanswer).我想写类似thisfiddle的东西在多个输入中使用is-number指令。请注意,由于我的输入中有各种不同的指令,因此我不能使用上述答案更新中建议的相同模板。var$scope;varapp=angular.module('myapp',[]);app.controller('Ctrl',function($scope){$scope.myNnumber1=1;$scope.myNnumber2=1;});app.directiv

javascript - 从具有 ngIf 指令的输入中获取值时出错

我得到一个异常ErrorTypeErrorandErrorContext单击提交按钮时。如果我将删除ngIf指令它将按异常(exception)情况工作,完整的StackTrace:PlayerNameFormComponent.html:8ERRORTypeError:Cannotreadproperty'value'ofundefinedatObject.eval[ashandleEvent](PlayerNameFormComponent.html:8)athandleEvent(core.js:13547)atcallWithDebugContext(core.js:15056

javascript - AngularJS 指令中的单元测试私有(private)函数

如何对在指令内定义的函数进行单元测试,如下面的myFunc?angular.module('myApp').directive('myDir',[function(){varmyFunc=function(arg){//codeinhere.};return{restrict:'A',scope:{},link:function(scope,element){}};}]);或者您如何定义我不想在指令之外公开的可测试指令特定函数? 最佳答案 最常见的方法是不测试私有(private)方法,而是测试公开其行为的公共(public)接口(