2016-11-15 4 views
0

AngularJSの新機能 エラーが発生したアプリケーションを作成しましたが、コード全体が表示されません。角度コードを持つコードの部分は表示されませんでした。Error:ng:areq Bad ANGULARJSで定義されていない引数と引数

MAIN.jsはファイル

var app = angular.module('app', [ 
'ngRoute', 
'artistController' 
]); 
app.config(['$routeProvider', function ($routeProvider) { 
$routeProvider. 
when('/list' , { 
templateUrl: 'list/list.html', 
controller: 'artistController' 
}).otherwise({ 
redirectTo: '/list' 
}); 
}]); 

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

artistController.controller("ListController", [ 
    "$scope", "$http" ,function ($scope , $http) { 
    $http.get('file:///C:/wamp/www/angular - copy/data.json').success(function (data) { 
    $scope.artists = data; 
    }); 
} 
]); 

index.htmlを

<!DOCTYPE html> 
<html ng-app="app"> 
<head> 
<meta charset="utf-8"> 
<title>angular</title> 
<link rel="stylesheet" href="file:///C:/wamp/www/angular/bootstrap-3.3.7- dist/css/bootstrap.min.css" media="screen" title="no title"> 
<link rel="stylesheet" href="file:///C:/wamp/www/angular - copy/main.css" media="screen" title="no title"> 
<script src="file:///C:/wamp/www/angular/angular-1.5.8/angular.min.js" charset="utf-8"></script> 
<script src="file:///C:/wamp/www/angular/angular-1.5.8/angular-route.min.js" charset="utf-8"></script> 
<script src="file:///C:/wamp/www/angular - copy/main.js" charset="utf-8">  </script> 
</head> 
<body> 
<div class="containor" ng-view></div> 
</body> 
</html> 

するlist.html

<div> 
<h2>Search directory</h2> 
<label>Search:</label> 
<input placeholder="Search for your person" autofocus="" ng-model="query"> </input> 
    <label>By: 
    <select ng-model="artistOrder"> 
    <option value="lastName">lastName</option> 
    <option value="firstName">firstName</option> 
    </select> 
    </label> 
</div> 
<ul class="background" ng-controller="ListController"> 
<li class="center" ng-repeat="x in artists | filter:query | orderBy:artistOrder"> 
    <img src="img.png" alt="photo" /> 
    <h1 class="col-lg-4">{{ x.firstName | uppercase }}</h1> 
    <h2 class="col-lg-5">{{ x.lastName }}</h2> 
</li> 
</ul> 
</section> 

クロムで私はエラーが発生しましたArgument 'artistController' is not aNaNunction, got undefined

ご存知ですか? AngularJS Documentation on Controllersを見てみましょう

angular.module('app') //if you do var app = ..., you can also do app.controller 
     .controller('ListController', ListController); 

ListController.$inject = [ "$scope", "$http" ]; 

function ListController($scope, $http){ 
    $http.get('file:///C:/wamp/www/angular - copy/data.json').success(function (data) { 
    $scope.artists = data; 
    }); 
} 

: おかげで、あなたが他のエラーをしていないと仮定すると

+0

あなたのアプリケーションモジュールからartistControllerを外す必要があるようです。あなたはちょうどそれが自分のもので公開されていると宣言しているので、あなたのng-appモジュール(つまり、 "app")には見つかりません。 –

答えて

0

をに関しては、あなたはあなたに、コントローラを変更する必要があります。

+0

私はあなたのコードをアプリケーションに追加しますが、まだ動作しません。もう少しお手伝いできますか? thanks –

+0

また、アプリケーションの依存関係からartistControllerを削除する必要があります – AndreaM16

関連する問題