AngularJS:奇怪的自定义指令

AngularJS : Weird custom directive

我是 AngularJS 的新手。我创建了我的第一个自定义指令,名称为 my-customer,方法是从旁边复制并将其粘贴到我的工作文件中。当我尝试自己构建它时,我看到了奇怪的行为,因为如果我尝试使用 my-customer 访问指令,它不会在屏幕上显示任何内容。

test.directive('my-customer',function(){
code...
}   

当我看到原始示例时,作者使用 myCustomer 名称访问相同的指令。 angular 如何将 html 属性转换为指令名称。 因为如果我尝试使用 mycustomer 它仍然一无所获。名称中有多个 - 的控制器怎么样 my-customer-a

<div ng-app="myapp">

            <div ng-controller="Controller">
                <div id="test" my-customer></div>
            </div>


        </div>


var test = angular.module('myapp', [])
.controller('Controller', ['$scope', function($scope) {
  $scope.customer = {
    name: 'Naomi',
    address: '1600 Amphitheatre'
  };
}]);
test.directive('myCustomer',function(){

    return{

        template:'Name :{{customer.name}} Address: {{customer.address}}'
    }
});

Angular 在内部将此 my-customer 代码转换为驼峰式。
在这种情况下,多个 - 将转换为驼峰式。
例如:my-name-is-intekhab 将转换为 myNameIsIntekhab

您也可以使用 :data-

这来自 Angular 网站

The normalization process is as follows:

Strip x- and data- from the front of the element/attributes.
Convert the :, -, or _-delimited name to camelCase.