为什么指令中的数据名称会出错?

why the name of the data in the directive give error?

我在 html 文件中有这个:

<prevalence ng-if="model.mode == 'Prevalence'" data="prevalenceData" colors="colors" maxL="maxL"></prevalence>

并且指令中的 maxL 未定义。如果我将 L 更改为 l => maxL 到 maxl,它就被定义了。 可能是什么原因?我对它进行了一些变体测试,发现问题出在大写字母上。

指令js文件中有:

angular.module('x').directive('prevalence', [function () {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            data: '=',
            colors: '=',
            maxL: '='
        },

谢谢!

将 HTML 中的 maxL 属性更改为 max-l,如下所示:

<prevalence ng-if="model.mode == 'Prevalence'" data="prevalenceData" colors="colors" max-l="maxL"></prevalence>

HTML 不区分大小写,因此 angular 编译器假定指令中的 camelCase 属性在 HTML 中是实际的 camel-case 虚线。