Javascript 棱角分明,很难让指令发挥作用

Javascript 棱角分明,很难让指令发挥作用,javascript,angularjs,angularjs-directive,Javascript,Angularjs,Angularjs Directive,我似乎很难让我的指令发挥作用,我想我可能注册不正确,但我似乎不知道怎么做。可能是命名约定? 这是我的- 我的指示- 'use strict'; angular.module('demoApp') .directive('packeryAngular', ['$rootScope', '$timeout', function($rootScope, $timeout) { return { restrict: 'A', scope: true, link: function(scop

我似乎很难让我的指令发挥作用,我想我可能注册不正确,但我似乎不知道怎么做。可能是命名约定? 这是我的-

我的指示-

'use strict';

angular.module('demoApp')
.directive('packeryAngular', ['$rootScope', '$timeout',
function($rootScope, $timeout) {
return {
  restrict: 'A',
  scope: true,
  link: function(scope, element, attrs) {

};

}
]);
在我的节目中,我只是这样称呼它

<div packeryAngular>
但是,当我这样做时,控制台中会出现以下错误:

Error: [$injector:modulerr] Failed to instantiate module packeryAngular due to:
Error: [$injector:nomod] Module 'packeryAngular' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

所以,我对这个很陌生,但我不完全确定我在这里做错了什么,我试图复制其他工作示例,但似乎无法让它工作。非常感谢您的帮助,非常感谢您的阅读

必须在节点上放置以下属性:

<div packery-angular>

注册指令时,名称必须使用小写形式。但是HTML不能很好地处理属性名称中的大写字母,因此AngularJS希望大写字母被破折号替换,破折号后跟相应的小写字母


因此,javascript代码中的指令名是
yourDirectiveName
,但在HTML代码中,它必须被称为
your directive name

,您必须在节点上放置以下属性:

<div packery-angular>

注册指令时,名称必须使用小写形式。但是HTML不能很好地处理属性名称中的大写字母,因此AngularJS希望大写字母被破折号替换,破折号后跟相应的小写字母


因此,javascript代码中的指令名是
yourDirectiveName
,但在HTML代码中,它必须被称为
your directive name

,您不需要注入指令,只需要在HTML中使用它。指令的第二个大写字母开头的单词会变小,只需使用连字符,因此,在接下来的所有大写字母中,第一个字母将变小,并在前面加上连字符,就像CustomDirective变为CustomDirective一样

<div packery-angular>

您不需要注入指令,只需要在html中使用它。指令的第二个单词(大写字母首字母)将变小,然后使用连字符,因此接下来所有大写字母首字母将变小,并在前面加上连字符,就像您的CustomDirective变为自定义指令一样

<div packery-angular>