草庐IT

set_state

全部标签

javascript - Angular UI 路由器 : Different states with same URL?

我的应用程序的登录页面有两种状态:home-public、home-logged-in。现在我想在同一个URL上显示两种状态,但让Controller和模板取决于用户session(用户是否登录?)。有什么办法可以实现吗? 最佳答案 您可以有一个基本状态来控制要加载的状态,并且您可以简单地让该基本状态的子状态没有url:.state('home',{url:"/home",templateUrl:"....",controller:function($scope,$state,authSvc){if(authSvc.userIsLo

javascript - react ( Facebook ): managed state of controlled checkboxes

我在尝试使用React创建一个用于选择和取消选择其他单个复选框(全选/取消全选)的复选框时遇到了一个小问题。.我读过http://facebook.github.io/react/docs/forms.html并发现controlled和notcontrolled之间存在差异秒。我的测试代码如下:varTest=React.createClass({getInitialState:function(){return{data:[{id:1,selected:false},{id:2,selected:false},{id:3,selected:false},{id:4,selected

javascript - Map 和 Set 有什么区别?

JavaScriptMap和Set对象都是iterableobjects.两者都通过[key,value]对存储对象。什么时候使用哪个?它们有什么区别? 最佳答案 假设您谈论的是ES6类型,即使Set,它们也不是相同的数据结构。可以用Map来实现.您对Map的定义是正确的,但是Set是唯一值的集合,这与可以重复的数组不同。vararray=[1,2,3,3];varset=newSet(array);//Willhave[1,2,3]assert(set.size,3);varmap=newMap();map.set('a',1);

javascript - jQuery 完整日历 : set a different color to each event from front-end

这就是我使用插件的方式:jQuery(document).ready(function(){jQuery('#booking-calendar').fullCalendar({header:{left:'prev,next',center:'title',right:'month,basicWeek,basicDay'},editable:true,events:'/bookings-feed.php'});jQuery('#apartment-selector').change(function(){apartment=jQuery(this).val()jQuery('#booki

javascript - 未捕获的 InvalidStateError : Failed to execute 'send' on 'WebSocket' : Still in CONNECTING state

当我的页面加载时,我尝试向服务器发送消息以启动连接,但它不起作用。这个脚本block靠近我的文件的顶部:varconnection=newWrapperWS();connection.ident();//varautoIdent=window.addEventListener('load',connection.ident(),false);大多数时候,我会在标题中看到错误:UncaughtInvalidStateError:Failedtoexecute'send'on'WebSocket':StillinCONNECTINGstate所以我尝试捕获异常,如下所示,但现在看来Inva

javascript - 选择 2 : how to set data after init?

初始化select2后需要设置一个数据数组。所以我想做这样的事情:varselect=$('#select').select2({});select.data([{id:1,text:'value1'},{id:1,text:'value1'}]);但是我得到以下错误:Option'data'isnotallowedforSelect2whenattachedtoaelement.;我的HTML:我应该使用什么来代替选择元素?我需要设置搜索项的来源 最佳答案 在加载中:$.each(data,function(index,value

javascript - window.onpopstate, event.state == null?

我已经阅读了关于StackOverflow的几个问题/答案并用Google搜索了这个问题,我似乎无法让event.state返回任何东西,除了null.我知道它不适用于jQuery事件,但是当我这样做时:window.onpopstate=function(e){console.log(e.state)}与jQuery.ajax成功调用类似的东西history.pushState({lastUrl:data.State},data.Title,data.UrlKey);Chrome(v19)或Firefox(v12)都没有返回null?我错过了什么吗?只是没有完全实现吗?

javascript - 未捕获的类型错误 : Cannot set property 'position' of undefined

我有这段代码给我奇怪的错误信息UncaughtTypeError:Cannotsetproperty'position'ofundefined这是一个jQuery插件的内部,用于在弹出窗口中显示谷歌地图。我在其他地方使用代码,在那里工作正常-这里唯一的区别似乎是我现在在弹出窗口中使用它。我是否遗漏了范围问题或其他问题?所有变量(如geocoderParams和latlng)都按应有的方式填充。谷歌搜索错误消息没有发现任何有值(value)的信息。调用google.maps.Map()时会触发错误消息。self=$(this)self.hide()geocoder=newgoogle.m

javascript - Angular .js : set element height on page load

我是AngularJS新手。我想创建高度取决于窗口高度的网格(使用ng-grid),即。$('.gridStyle').height($(window).height()-100);我写了指令:app.directive('resize',function($window){returnfunction(scope,element){functionapplyHeight(){scope.height=$window.innerHeight;$('.gridStyle').height(scope.height-100);}angular.element($window).bind('

javascript - Protractor 测试 : How to set the value of text elements in a login form?

我正在用Protractor为Angular应用程序编写测试。我想填写一个登录表单并提交。我该怎么做?我已经走到这一步了,但我不知道如何设置电子邮件和密码字段的值。describe('Thedashboard',function(){ptor=protractor.getInstance();beforeEach(function(){ptor.get('#/dashboard');varemail=ptor.findElement(protractor.By.model('email'));varpassword=ptor.findElement(protractor.By.mode