HTML元素属性带连字符的名称是自动转换为驼峰 [英] HTML element attribute names with hyphens are auto-converted to camelcase

查看:810
本文介绍了HTML元素属性带连字符的名称是自动转换为驼峰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个自定义的AngularJS指令来创建一个谷歌地图,我已经在我的自定义标签内存储的属性部分的谷歌地图选项:

I'm building a custom AngularJS directive to create a google map, and I've stored some of the google map options in custom attributes within my tag:

<googlemap zoom-control="true" …></googlemap>

角的指令编译方法有参数(tElement,tAttrs,transclude);当我登录 tAttrs 到控制台,该对象已转换连字符驼峰与名称属性:

Angular's directive compile method has parameters (tElement, tAttrs, transclude); when I log tAttrs to the console, the object has properties with names that have converted hyphens to camelCase:

谁在做这个角或浏览器(在Firefox和放大器检查;浏览器)?我可以依靠这种行为?

Who is doing this—Angular or the browser (checked in Firefox & Chrome)? Can I rely on this behaviour?

P.S。当我检查的DOM中,HTML元素的属性还是有连字符。

P.S. When I check the DOM, the attributes of the html element still have hyphens.

推荐答案

角是做什么的。是的,你可以依靠它:

Angular is doing it. Yes you can rely on it:

属性页:

一个共享对象的属性。该数值反映了当前绑定状态{{}}。需要正常化,因为所有这些都为等同于角处理:搜索
    &LT;跨度NG:绑定=一个NG绑定=数据-NG-绑定=一个X-NG-绑定=一个&GT;

A shared object between directive compile / linking functions which contains normalized DOM element attributes. The the values reflect current binding state {{ }}. The normalization is needed since all of these are treated as equivalent in Angular:
<span ng:bind="a" ng-bind="a" data-ng-bind="a" x-ng-bind="a">

这篇关于HTML元素属性带连字符的名称是自动转换为驼峰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆