search

Home  >  Q&A  >  body text

angular.js - directive naming rules?

Directive can only be composed of lowercase letters?

1

2

3

4

5

6

7

8

<code>.directive('名称', function() {

    return {

        restrict: 'AE',

        template: '<p>Hi there</p>',

        replace: true

    };

});

</code>

For example,
hello ok
helloA not work
Hello not work
hello_a not work
hello-a not work

What should I do if I want to name it with a phrase?

phpcn_u1582phpcn_u15822861 days ago827

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

    1

    2

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

    </code>

    But this is required when defining instructions

    1

    2

    <code>javascript</code><code>myApp.directive("myNewDirective", function(){...});

    </code>

    reply
    0
  • Cancelreply