草庐IT

data-transient-attributes

全部标签

javascript - AngularJS 指令 : put a call function in an attribute, 不包含另一个属性

我在追求什么我想创建一个ngLoad我网页上的图像指令。这是我的首选标记:我有什么JSFiddle现在,我有一个imgLoad带有ngLoad的指令在scope中指定,像这样:varapp=angular.module('app',[]);app.directive('imgLoad',[function(){return{restrict:'A',scope:{loadHandler:'&ngLoad'},link:function(scope,element,attr){element.on('load',scope.loadHandler);}};}]);生成的标记是:编辑:我之

javascript - jQuery 解析 XML : get an element with a specific attribute

我正在开发一个HTML5应用程序。我想像这样解析XML:......我想获取具有属性lang="en"的名称和描述。我开始写代码,但我不知道如何完成:functionloadCards(lang){$.ajax({type:"GET",url:'data/english.xml',dataType:"xml",success:parseCardsXml});}functionparseCardsXml(xml){$(xml).find('Card').each(function(){varid=$(this).attr('id');varname=$(this).find('name'

javascript - 查找位置为 :attribute 的元素

我会尝试在我的页面中找到所有“绝对”元素;使用jQuery我虽然会是这样的$('[position="absolute"]')但是在ff10.0.2上我找不到元素...此外,我无法在http://api.jquery.com/attribute-equals-selector/上运行示例代码这个语法有问题吗? 最佳答案 你可以使用filter()$('*').filter(function(){varposition=$(this).css('position');returnposition==='absolute';});你不能

Javascript/jQuery : Reordering divs according to data-attribute values

这个问题在这里已经有了答案:关闭9年前。PossibleDuplicate:Sortelementbynumericalvalueofdataattribute我想根据设置在它们上的数据属性重新组织div,范围从最高整数到最低整数。现在,我将所有数据插入一个数组并对其进行排序,但我不确定如何进行。我如何使用它来重组其父div内的div?varprices=newArray();$(this).children('.listing-item').each(function(){varprice=parseInt($(this).attr('data-listing-price'));pr

javascript - Angular : Pass $scope variable as directive attribute

我试图将$scope变量值作为属性传递给自定义指令,但它不起作用。这是HTML代码:{{q.question}}指令是,这里是指令代码:app.directive('checkList',function(){return{restrict:'E',template:function(elem,attrs){console.log(attrs.name);return'YesNo'},link:function(scope,elem,attrs){}};})我正在记录属性attrs.name但我得到的值是"{{q.id}}"而不是q.id的实际值 最佳答案

javascript - Angular 力矩 : Moment Timezone has no data for America/New_York

从服务器收到的日期是UTC时区,我需要将其转换为特定时区,例如:America/New_York。以下是相同的代码但是在这样做时我得到了以下错误:MomentTimezonehasnodataforAmerica/New_York.Seehttp://momentjs.com/timezone/docs/#/data-loading/.但是America/New_York是moment的已知时区,但它仍然要求我添加时区。 最佳答案 您需要加载以下所有内容:时刻时刻时区moment-timezone的时区数据Angular矩关于mom

javascript - 获取 : post json data, application/json 更改为 text/plain

我使用的是chrome53.0.2785.116m(64位)。我在devtools上得到了以下标题。该问题标有“//”注释。内容类型真的不允许我们将其设置为application/json,我已经尝试了100种不同的方法。importfetchfrom'isomorphic-fetch';constoption={method:'POST',mode:'no-cors',headers:{'Accept':'application/json','Content-Type':'application/json'},body:JSON.stringify({'aa':'bb'})}fetc

Javascript:setAttribute() 对比element.attribute = 设置 "name"属性的值

所以我正在学习操作DOM,我注意到一件有趣的事情:假设我想使用“.”设置元素的name属性。点符号:element.name="someName";console.log(document.getElementsByName("someName")[0]);//returns"undefined"??但是,如果我使用document.setAttribute()方法,它工作正常:element.setAttribute("name","someName");console.log(document.getElementsByName("someName")[0]);//returnst

javascript - AngularJS 用户界面路由器 : how to resolve typical data globally for all routes?

我有一个与服务器通信并返回的AngularJS服务应用程序不同部分的翻译:angular.module('utils').service('Translations',['$q','$http',function($q,$http){translationsService={get:function(section){if(!promise){varq=$q.defer();promise=$http.get('/api/translations',{section:section}).success(function(data,status,headers,config){q.res

javascript - Uncaught TypeError : this. state.data.map 不是函数

我是React的新手,见过一些类似的问题,但没有找到为什么会这样。我收到“未捕获的类型错误:this.state.data.map不是函数”。这是代码。请帮助找出问题所在。classAudiensesextendsReact.Component{constructor(props){super(props);this.state={data:''};this.loadFromServer=this.loadFromServer.bind(this);this.childeDelete=this.childeDelete.bind(this);this.childeEdit=this.c