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

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

阅读 3.6k
1 个回答

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

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

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

但是定义指令时需要这样

javascriptmyApp.directive("myNewDirective", function(){...});
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进