2015-12-22 62 views
2

我有一個指令,我想在我的應用程序文件中添加以便它可以在控制器中使用。 這是文件夾結構: enter image description here如何使用角度在App文件中添加指令依賴關係

這是我的指令dragAndDrop.js文件:

var app= angular.module('rulesApp',[]); 
    app.directive('droppable', function() { 
    return { 
    //some code here 
} 
} 

這是我的rulesApp文件:

var app = angular.module('rulesApp', []); 

但有了這個代碼,它不採摘指令文件。這是在chrome上創建的結構。但它不包含dragAndDrop.js文件。

enter image description here

任何人都可以請建議什麼,我在這裏失蹤。

+0

檢查該文件作爲它的表現?在它上面標記。這是否包含在您的解決方案中? – Prathyush

+0

你是否在你的html/php/jsp文件中包含了'dragAndDrop.js'文件,其中包含你的腳本? – Jas

+0

我覺得呢?可能是因爲它是一個新創建的文件..不在SVN中提交但 –

回答

1

我不確定,但對我來說,好像你定義模塊兩次。

試試這個:

var app= angular.module('rulesApp') 
     .directive('droppable', function() { 
      return { 
       //some code here 
      } 
     } 

這是你如何定義模塊:

var app = angular.module('rulesApp', []); 

這是你如何得到一個模塊

var app = angular.module('rulesApp'); 
相關問題