登录

angular.js - directive命名规则?

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

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

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

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

# AngularJS
phpcn_u1582phpcn_u15822112 天前443 次浏览

全部回复(1) 我要回复

  • 迷茫

    迷茫2017-05-15 16:54:18

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

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

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

    但是定义指令时需要这样

    javascriptmyApp.directive("myNewDirective", function(){...});
    

    回复
    0
  • 取消回复发送