首页 > directive命名规则?

directive命名规则?

directive只能由小写字母组成吗?

.directive('名称', function() {
    return {
        restrict: 'AE',
        template: '<div>Hi there</div>',
        replace: true
    };
});

例如,
hello ok
helloA not work
Hello not work
hello_a not work
hello-a not work

我的要一个词组命名怎么办?


采用驼峰式命名
如:hello A not work
命名为:helloANotWork

详细规则:
在html中使用如下方式

html<my-new-directive></my-new-directive>

但是定义指令时需要这样

javascriptmyApp.directive("myNewDirective", function(){...});
【热门文章】
【热门文章】