草庐IT

current_condition

全部标签

javascript - 无法根据文档在 Angular ui-router 中访问 $state.current.data

我正在尝试动态更新页面标题。考虑这样定义的状态:$stateProvider.state('login',{url:'/login',templateUrl:'/templates/views/login.html',controller:'AuthCtrl',data:{title:'Login'}}在页面的HEAD部分:根据tothedocumentation,Iamsupposedtobeabletoaccessmycustomdataproperty:app.directive("pageTitle",function($state){return{restrict:'A',t

javascript - react : potential race condition for Controlled Components

theReacttutorial中有如下代码:classNameFormextendsReact.Component{constructor(props){super(props);this.state={value:''};this.handleChange=this.handleChange.bind(this);this.handleSubmit=this.handleSubmit.bind(this);}handleChange(event){this.setState({value:event.target.value});}handleSubmit(event){alert

javascript - 创建小书签 : Append current URL with specific string

我正在尝试创建一个小书签,它将更改我当前所在页面的URL,并加载一个更改了URL字符串的新页面。我已经查看了许多关于小书签的其他主题,但我还没有找到适合我的解决方案。我希望能够更改如下所示的URL:http://mywebsite.com/directory/page.html?referral=Google&visit=1到:http://mywebsite.com/directory/page.html?dog=Fido&cat=Mittens三个目标:1)在?之后删除现有URL中的任何内容标记。2)在问号后附加“dog=Charlie&cat=Mittens”。3)立即使用新UR

javascript - jQuery/JS : Get current URL parent directory

来自:http://www.site.com/example/index.html我怎样才能得到:http://www.site.com/example/并使用Javascript以及如何使用jQuery将其存储到变量中。提前致谢。 最佳答案 varmyURL="http://www.site.com/example/index.html";varmyDir=myURL.substring(0,myURL.lastIndexOf("/")+1); 关于javascript-jQuery/

javascript - 从 'current' Controller 访问 'root' 范围

我有一个Controller,我认为它是我的“根”Controller,它是用ng-controller属性声明的Controller,然后是通过动态实例化的其他一些Controller$路由提供者。我想声明一个函数,该函数可通过任何动态/子Controller范围内的ng-click属性使用。我可以在我的根Controller上声明这个函数,例如$scope.announce=function(){alert($scope.specificName);}然后我在所有“子”Controller的所有作用域中看到它,但是此函数中使用的$scope是根Controller的本地变量,而不是

javascript - 误报 "Lexical declarations require ECMAScript 6"和 "TypeScript 1.x feature. Current language is 1.4"错误消息

在将TypeScript更新到版本1.7(目前最新版本)后,我一直看到Resharper指出错误,例如在使用namespace、const和let,即使这个版本的TypeScript应该支持它们。例如:TypeScript1.x功能。当前语言是1.4和词法声明(let和const)需要ECMAScript6编译器目标。当前目标是ECMAScript5。 最佳答案 我的Resharper(10.0.1)版本似乎无法检测到TypeScript版本。要解决此问题,您可以手动指定版本。由于此版本的Resharper(发布时为最新版本)不支持

javascript - Chrome 扩展 : How to get current webpage url from background. html

据我所知,直接获取tab.url是不可能的(只能在popup.html中实现)并且进行消息传递也需要打开popup.html。无论如何绕过这个并从background.html获取当前页面url?我最擅长的是消息传递,我在background.html中使用了这段代码varbg=chrome.extension.getPopupPage();varmyURL=bg.myURL;然后在popup.html中我有:chrome.tabs.getSelected(null,function(tab){varmyURL=tab.url;})无论如何,以上根本不起作用。有人知道无需实际打开弹出窗

javascript - 如何在 JavaScript 中使用 array reduce with condition?

所以我有一个数组constrecords=[{value:24,gender:"BOYS"},{value:42,gender:"BOYS"},{value:85,gender:"GIRLS"},{value:12,gender:"GIRLS"},{value:10,gender:"BOYS"}]我想得到sum所以我使用了JavaScriptarrayreduce函数并得到了它。这是我的代码:someFunction(){returnrecords.reduce(function(sum,record){returnsum+record.value;},0);}通过该代码,我得到了正确

goroutine race condition 解决方案

我正在尝试了解如何为以下代码修复此竞争条件。sayHello:=func(){fmt.Println("Hellofromgoroutine")}gosayHello()time.Sleep(1)fmt.Println("Hello,playground")期望:我只想知道最好的解决方案是什么,我应该使用WaitGroup还是有更好的解决方案?所以我想出了以下解决方案:varwgsync.WaitGroup//deferwg.Wait()sayHello:=func(){deferwg.Done()fmt.Println("Hellofromgoroutine")}wg.Add(1)g

mysql - gocraft/dbr : How to JOIN with multiple conditions?

我使用golang开发网络应用程序。我使用图书馆gocraft/dbr作为O/R映射器。我有两个表:image和entry。我加入了他们的table,我想获得image_url。typeImagestruct{ImageUrldbr.NullString`db:"image_url"`}typeEntrystruct{CompanyImageIDdbr.NullInt64`db:"company_image_id"`CompanyImageImageEyecatchIamgeIDdbr.NullInt64`db:"eyecatch_image_id"`EyecatchImageImag