2017-11-20 17 views
0

私は以下のコードを使用しています。しかし、私はエラーを取得しています。キャッチエラー:[$ injector:nomod]。モジュール名は同じです。なぜこのエラーが出るのかわかりません。助けてください。どこでも構文や名前などを確認しましたが、問題は見つかりませんでした。私は何かシンプルなことを忘れてしまったようですが、正確にどこでミスをしたのか分かりません。

\t \t \t angular.module("demo").controller("SimpleDemoController", function($scope) { 
 

 
\t \t \t \t $scope.models = { 
 
\t \t \t \t \t selected: null, 
 
\t \t \t \t \t lists: {"A": [], "B": []} 
 
\t \t \t \t }; 
 

 
\t \t \t \t // Generate initial model 
 
\t \t \t \t for (var i = 1; i <= 3; ++i) { 
 
\t \t \t \t \t $scope.models.lists.A.push({label: "Item A" + i}); 
 
\t \t \t \t \t $scope.models.lists.B.push({label: "Item B" + i}); 
 
\t \t \t \t } 
 

 
\t \t \t \t // Model to JSON for demo purpose 
 
\t \t \t \t $scope.$watch('models', function(model) { 
 
\t \t \t \t \t $scope.modelAsJson = angular.toJson(model, true); 
 
\t \t \t \t }, true); 
 

 
\t \t \t }); \t \t
\t \t \t /** 
 
\t \t \t * The dnd-list should always have a min-height, 
 
\t \t \t * otherwise you can't drop to it once it's empty 
 
\t \t \t */ 
 
\t \t \t .simpleDemo ul[dnd-list] { 
 
\t \t \t \t min-height: 42px; 
 
\t \t \t \t padding-left: 0px; 
 
\t \t \t } 
 

 
\t \t \t /** 
 
\t \t \t * The dndDraggingSource class will be applied to 
 
\t \t \t * the source element of a drag operation. It makes 
 
\t \t \t * sense to hide it to give the user the feeling 
 
\t \t \t * that he's actually moving it. 
 
\t \t \t */ 
 
\t \t \t .simpleDemo ul[dnd-list] .dndDraggingSource { 
 
\t \t \t \t display: none; 
 
\t \t \t } 
 

 
\t \t \t /** 
 
\t \t \t * An element with .dndPlaceholder class will be 
 
\t \t \t * added to the dnd-list while the user is dragging 
 
\t \t \t * over it. 
 
\t \t \t */ 
 
\t \t \t .simpleDemo ul[dnd-list] .dndPlaceholder { 
 
\t \t \t \t background-color: #ddd; 
 
\t \t \t \t display: block; 
 
\t \t \t \t min-height: 42px; 
 
\t \t \t } 
 

 
\t \t \t .simpleDemo ul[dnd-list] li { 
 
\t \t \t \t background-color: #fff; 
 
\t \t \t \t border: 1px solid #ddd; 
 
\t \t \t \t border-top-right-radius: 4px; 
 
\t \t \t \t border-top-left-radius: 4px; 
 
\t \t \t \t display: block; 
 
\t \t \t \t padding: 10px 15px; 
 
\t \t \t \t margin-bottom: -1px; 
 
\t \t \t } 
 

 
\t \t \t /** 
 
\t \t \t * Show selected elements in green 
 
\t \t \t */ 
 
\t \t \t .simpleDemo ul[dnd-list] li.selected { 
 
\t \t \t \t background-color: #dff0d8; 
 
\t \t \t \t color: #3c763d; 
 
\t \t \t } \t \t
<!DOCTYPE html> 
 
<html> 
 
\t <head> 
 
\t \t <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.1/angular.min.js"></script> 
 
\t \t <script src="./angular-drag-and-drop-lists.js"></script> 
 
\t </head> 
 
\t <body ng-app="demo"> 
 
\t \t <!-- The dnd-list directive allows to drop elements into it. The dropped data will be added to the referenced list --> 
 
\t \t <ul dnd-list="list"> 
 
\t \t \t <!-- The dnd-draggable directive makes an element draggable and will transfer the object that was assigned to it. If an element was dragged away, you have to remove it from the original list yourself using the dnd-moved attribute --> 
 
\t \t \t <li ng-repeat="item in list" 
 
\t \t \t \t dnd-draggable="item" 
 
\t \t \t \t dnd-moved="list.splice($index, 1)" 
 
\t \t \t \t dnd-effect-allowed="move" 
 
\t \t \t \t dnd-selected="models.selected = item" 
 
\t \t \t \t ng-class="{'selected': models.selected === item}"> 
 
\t \t \t \t {{item.label}} 
 
\t \t \t </li> 
 
\t \t </ul> \t 
 
\t </body> 
 
</html>

+0

を注入している必要があり、角度の縮小さバージョンを使用しないでください。非圧縮を使用すると、通常より詳細なエラーが表示されます – devqon

+0

チップをありがとう。それに続くでしょう。 –

答えて

0

デバッグするときあなたのモジュールは、空の依存関係が

angular.module("demo",[]).controller("SimpleDemoController", function($scope) { 
+0

助けてくれてありがとう。 –

+0

それが助けられた場合 – Sajeetharan

+0

これはエラーを解決しました。しかし、関数内のコード($ scope)は呼び出されていません。理由を知っていれば、教えてください。関数内で何か間違っているのですか? –

関連する問題