search

Home  >  Q&A  >  body text

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

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

phpcn_u1582phpcn_u15822742 days ago747

reply all(1)I'll reply

  • 迷茫

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

    Using CamelCasenaming
    Such as: hello A not work
    Named: helloANotWork

    Detailed rules:
    Use the following method in html

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

    But this is required when defining instructions

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

    reply
    0
  • Cancelreply