草庐IT

is_repeated

全部标签

javascript - Chrome 扩展 : how to detect that content script is already loaded into a tab?

我的后台脚本中有以下代码:chrome.tabs.onUpdated.addListener(function(tabId,changeinfo,tab){if(changeinfo.status!=='complete')return;if(!matchesUrlFilters(tab.url))return;chrome.tabs.executeScript(tabId,{file:"jquery-1.7.1.min.js"},function(){chrome.tabs.executeScript(tabId,{file:"enhance.js"});});});但是,在某些情况

javascript - 类型错误 : 'undefined' is not a constructor (evaluating 'new JdRes())

我正在为AngularController编写jasmine测试规范。在这里,我收到错误TypeError:'undefined'isnotaconstructor(evaluating'newJdRes())-虽然我已经将其定义为JdRes=jasmine.createSpy('JdRes');Controller中的代码段如下function(myService,$scope,$attrs,$q,$parse){'usestrict';varJdRes,resource;JdRes=myService('JdRes');resource=newJdRes();}

javascript - 在嵌套的 ng-repeat 中过滤复杂对象

我想在嵌套的ng-repeat中过滤对象。HTML:Cityid:{{locations.city_id}}Pincode:{{detail.pin}}Controller:varmyApp=angular.module('myApp',[]);myApp.controller('MyController',function($scope){$scope.search=function(location){if($scope.selectedCityId===undefined||$scope.selectedCityId.length===0){returntrue;}if(loca

javascript - 使用 Firebug 网络面板计时 : What is the onload time?

我正在使用Firebug网络面板查看响应时间。在网络面板的状态栏上,摘要显示如下:10个请求90KB10.22秒(加载6.57秒)加载时间是什么意思?这是否意味着一旦从服务器接收到内容,页面又需要6.57秒才能变为可用(即onready事件完成)?注意:我正在测试的站点包含大量Qooxdoo组件和大量JavaScript。 最佳答案 你的页面初始化顺序是:主要脚本正文脚本加载以后的事所以'onload'是onload事件被抛出并完成执行的时间。Firebug中的onload时间全部初始化,包括onload事件本身。Onload等待页

javascript - Angular .js : two-way binding inside ng-repeat

我正在开发Angular应用程序。我想生成一个表单,其中包含任意数量的文本输入字段,并为每个单独的输入字段提供双向绑定(bind)。没有按钮,没有观察者。ng-model由于范围界定而无法正常工作(如果我没记错的话)。输入字段是从带有ng-repeat的数组生成的,如下所示:{{item.name}}我只想要一个简单的绑定(bind)来根据输入的变化更新Controller中的items数组。感谢任何帮助。 最佳答案 只需更改输入标签,使其显示为:注意ng-model没有花括号。工作代码:http://plnkr.co/edit/C

javascript - 在 DOM 中动态重新加载 ng-repeat 数据

我认为有以下代码:{{i.id}}我想要ng-repeat当从items添加/删除新值时动态触发.就像,如果一个新元素被添加到items的开头那么它应该在开始时动态呈现给DOM,如果一个元素被添加到items的末尾,类似地该项目应呈现为最后一个列表项。DOM的这种动态变化是否可能有Angular? 最佳答案 ng-repeat应该开箱即用。但是,您需要将push或unshift放入数组中,以便正确的watch触发。Angular将通过引用跟踪数组。这是一个workingplunker.HTML:HelloPlunker!{{item

javascript - 类型错误 : is not a function typescript class

我在typescript类中遇到以下错误,无法理解原因。我所做的只是尝试调用传递token的辅助函数。错误:posterror:TypeError:this.storeTokenisnotafunction(…)类:/***AuthenticationService:**Containsthehttprequestlogictoauthenticatethe*user.*/import{Injectable}from'@angular/core';import{Http,Response,Headers,RequestOptions}from'@angular/http';import

javascript - 实现 "this page is asking you to confirm that you want to leave"

这是当我想离开某些页面时Firefox发出的警告。根据我在上面看到的页面以及当我在填写表格后尝试关闭页面时出现此警告,我只能假设它在动态页面上工作。哪种技术用于实现此功能?我如何在一个简单的hello-world页面上自己实现它? 最佳答案 您基本上为beforeunload事件实现了一个处理程序。这使您可以警告用户他们有未保存的数据。伪代码:window.onbeforeunload=functionwarnUsers(){if(needToConfirm){//checktoseeifanychangestothedataent

javascript - InvalidStateError : An attempt was made to use an object that is not, 或不再可用

以下适用于Chrome但不适用于Firefox:varmyVideo=document.getElementById('myVideo')myVideo.currentTime=570在Firefox中它说InvalidStateError:Anattemptwasmadetouseanobjectthatisnot,orisnolonger,usable第2行。 最佳答案 当对象(在本例中为视频)加载不足,无法设置currentTime并向前跳时,就会发生该错误。您必须等到视频可以播放后才能设置currentTimevarmyVi

javascript - 在 AngularJS 中,如何使一个独立的范围继承自 ng-repeat 的范围

我正在尝试创建一个在ng-repeat循环中接收参数的自定义组件。因此,例如,假设我有一个名为“mycomp”的组件,它在ng-repeat中接收自定义参数“name”:在我的指令中,隔离范围定义如下:scope:{name:"@"}那是行不通的,因为ng-repeat为它迭代的每个元素创建了一个独立的范围。所以我最终得到了两个级别的范围。我该如何解决这个问题?我做错了什么吗?谢谢。 最佳答案 正如我在对您的原始问题的评论中所述,这已经得到解答。无论如何,总结如下:在您的模板中,声明您想要继承的模型,不要使用{{}}(因为使用括号会