Custom AngularJS directive including a dash in the name doesn't work

前端 未结 2 1899
后悔当初
后悔当初 2021-01-12 03:38

I\'ve written the following Angular directive that will add the \"required\" attribute to all children:

.directive(\"requireall\", function($compile) {
  ret         


        
相关标签:
2条回答
  • 2021-01-12 03:58

    Rename the directive to "requireAll";

    .directive("requireAll",…)
    

    And a directive named abcDef can be used as abc-def in the markup.

    0 讨论(0)
  • 2021-01-12 04:05

    Angular converts camelCasing to snake-casing, so your requireall directive needs to be renamed to requireAll, then you can use require-all in your markup (or data-require-all if you want to correctly markup custom tags). Confused me for a while at first.

    0 讨论(0)
提交回复
热议问题