angular元素标签特性规范化

it2022-05-09  22

我们自定义一个myCustomer指令,在模板中写作my-cusomer,为什么这样呢?<div ng-controller="Controller"> <div my-customer></div> </div>

var app=angular.module('app',[]);

app.directive('myCustomer',function(){

  return {

    restrict: 'ACE',

    template: ' hello world!'

       }

});

 元素的标签(tag)与特性(attributes)需要规范化。

html是大小写不敏感的,在DOM的元素,属性中使用的指令格式为,小写,连字符分隔的形式,如ng-model。

js中directive指令名称是大小写敏感的驼峰式形式,如ngModel。

规范化过程如下:

从元素,属性名中去掉x-和data-头。

把用:-, or _分隔的名称转换成驼峰式。

转载于:https://www.cnblogs.com/icyriver/p/7089469.html

相关资源:angular-popups浮动框

最新回复(0)