指令不在自己的模块中工作

时间:2015-05-31 22:10:36

标签: angularjs angularjs-directive

如果我以这种方式声明我的模块,我收到一个错误:“未捕获的错误:[$ injector:modulerr]”

angular.module('myApp.resumeDirectives',[])

.directive('nameResume',[
  function(){
    return {
        restrict: 'AE',
        template: '<h1 id="user-name">{{resume.name}} resume </h1>'
    };
  }
]);

这是我的指令文件中的代码 这是我主文件中的代码

var myApp=angular.module('myApp', [
  // ...
  'myApp.resumeDirectives'
]);

相反,如果我以这种方式声明指令,则指令正常工作。

myApp.directive('nameResume',[
  function(){
    return {
        restrict: 'AE',
        template: '<h1 id="user-name">{{resume.name}} resume </h1>'
    };
  }
]);

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您需要创建一个声明模块的文件,例如 index.js或您想要的任何名称并声明模块

JScrollPane

然后,将新文件注入脚本文件

相关问题