2016-09-08 26 views
0

インデックスファイルでng-viewを使用していますが、実行するたびにこのエラーがコンソールに表示されます。 スクリプトファイルの順序を変更しようとしましたが、動作していないようですが、引き続き引数 "ContactController"に関するエラーを出し続けます。Angular ng-view controller error

角度-route.js:1012エラー:[NG:AREQ]

Index.htmlと(ネイティブ)エラーでhttp://errors.angularjs.org/1.5.8/ng/areq?p0=ContactController&p1=not%20aNaNunction%2C%20got%20undefined

<!DOCTYPE html> 
<html lang="en" ng-app="confusionApp"> 

<head> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <!-- The above 3 meta tags *must* come first in the head; any other head 
     content must come *after* these tags --> 

    <title>Ristorante Con Fusion</title>  
     <!-- Bootstrap --> 
<!-- build:css styles/main.css --> 
    <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> 
    <link href="bower_components/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet"> 
    <link href="bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet"> 
    <link href="styles/bootstrap-social.css" rel="stylesheet"> 
    <link href="styles/mystyles.css" rel="stylesheet"> 
<!-- endbuild --> 

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
    <!--[if lt IE 9]> 
     <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> 
     <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
    <![endif]--> 
</head> 

<body> 
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> 
     <div class="container"> 
      <div class="navbar-header"> 
       <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> 
        <span class="sr-only">Toggle navigation</span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
       </button> 
       <a class="navbar-brand" href="#/"><img src="images/logo.png" height=30 width=41></a> 
      </div> 
      <div id="navbar" class="navbar-collapse collapse"> 
       <ul class="nav navbar-nav"> 
        <li class="active"><a href="#/"> 
         <span class="glyphicon glyphicon-home" 
         aria-hidden="true"></span> Home</a></li> 
        <li><a href="#/aboutus"> 
         <span class="glyphicon glyphicon-info-sign" 
         aria-hidden="true"></span> About</a></li> 
        <li><a href="#/menu"> 
         <span class="glyphicon glyphicon-list-alt" 
         aria-hidden="true"></span> 
         Menu</a></li> 
        <li><a href="#/contactus"> 
        <i class="fa fa-envelope-o"></i> Contact</a></li> 
       </ul> 
      </div> 
     </div> 
    </nav>   

    <header class="jumbotron"> 

     <!-- Main component for a primary marketing message or call to action --> 

     <div class="container"> 
      <div class="row row-header"> 
       <div class="col-xs-12 col-sm-8"> 
        <h1>Ristorante con Fusion</h1> 
        <p style="padding:40px;"></p> 
        <p>We take inspiration from the World's best cuisines, and create 
        a unique fusion experience. Our lipsmacking creations will 
        tickle your culinary senses!</p> 
       </div> 
       <div class="col-xs-12 col-sm-2"> 
       <p style="padding:20px;"></p> 
       <img src="images/logo.png" class="img-responsive"> 
       </div> 
       <div class="col-xs-12 col-sm-2"> 
       </div> 
      </div> 
     </div> 
    </header> 

     <div ng-view></div> 

    <footer class="row-footer"> 
     <div class="container"> 
      <div class="row">    
       <div class="col-xs-5 col-xs-offset-1 col-sm-2 col-sm-offset-1"> 
        <h5>Links</h5> 
        <ul class="list-unstyled"> 
         <li><a href="#">Home</a></li> 
         <li><a href="#">About</a></li> 
         <li><a href="#">Menu</a></li> 
         <li><a href="#">Contact</a></li> 
        </ul> 
       </div> 
       <div class="col-xs-6 col-sm-5"> 
        <h5>Our Address</h5> 
        <address> 
         121, Clear Water Bay Road<br> 
         Clear Water Bay, Kowloon<br> 
         HONG KONG<br> 
         <i class="fa fa-phone"></i>: +852 1234 5678<br> 
         <i class="fa fa-fax"></i>: +852 8765 4321<br> 
         <i class="fa fa-envelope"></i>: 
         <a href="mailto:[email protected]"> 
         [email protected]</a> 
        </address> 
       </div> 
       <div class="col-xs-12 col-sm-4"> 
        <div class="nav navbar-nav" style="padding: 40px 10px;"> 
         <a class="btn btn-social-icon btn-google-plus" href="http://google.com/+"><i class="fa fa-google-plus"></i></a> 
         <a class="btn btn-social-icon btn-facebook" href="http://www.facebook.com/profile.php?id="><i class="fa fa-facebook"></i></a> 
         <a class="btn btn-social-icon btn-linkedin" href="http://www.linkedin.com/in/"><i class="fa fa-linkedin"></i></a> 
         <a class="btn btn-social-icon btn-twitter" href="http://twitter.com/"><i class="fa fa-twitter"></i></a> 
         <a class="btn btn-social-icon btn-youtube" href="http://youtube.com/"><i class="fa fa-youtube"></i></a> 
         <a class="btn btn-social-icon" href="mailto:"><i class="fa fa-envelope-o"></i></a> 
        </div> 
       </div> 
       <div class="col-xs-12"> 
        <p style="padding:10px;"></p> 
        <p align=center>© Copyright 2015 Ristorante Con Fusion</p> 
       </div> 
      </div> 
     </div> 
    </footer> 

<!-- build:js scripts/main.js --> 
<script src="bower_components/angular/angular.min.js"></script> 
    <script src="bower_components/angular-route/angular-route.min.js"></script> 
<script src="scripts/controllers.js"></script> 
    <script src="scripts/services.js"></script> 
     <script src="scripts/app.js"></script> 



<!-- endbuild --> 

</body> 

</html> 

Controllers.js:

angular.module('confusionApp', []) 
     .controller('MenuController', ['$scope', 'menuFactory', function($scope, menuFactory) { 

      $scope.tab ; 
      $scope.filtText = ''; 
      $scope.showDetails = false; 
      $scope.dishes=menuFactory.getDishes(); 
      $scope.select = function(setTab) { 
       $scope.tab = setTab; 

       if (setTab === 2) { 
        $scope.filtText = "appetizer"; 
       } 
       else if (setTab === 3) { 
        $scope.filtText = "mains"; 
       } 
       else if (setTab === 4) { 
        $scope.filtText = "dessert"; 
       } 
       else { 
        $scope.filtText = ""; 
       } 
      }; 

      $scope.isSelected = function (checkTab) { 
       return ($scope.tab === checkTab); 
      }; 

      $scope.toggleDetails = function() { 
       $scope.showDetails = !$scope.showDetails; 
      }; 

     }]) 

     .controller('ContactController', ['$scope', function($scope) { 

      $scope.feedback = {Name:"",stars:""}; 

      var channels = [{value:"tel", label:"Tel."}, {value:"Email",label:"Email"}]; 

      $scope.channels = channels; 
      $scope.invalidChannelSelection = false; 

     }]) .controller('DishCommentController', ['$scope', function($scope) { 

      //Step 1: Create a JavaScript object to hold the comment from the form 

      $scope.submitComment = function() { 
      console.log($scope.feedback.stars); 
       var x; 
       //Step 2: This is how you record the date 
       x= new Date().toISOString(); 

       // Step 3: Push your comment into the dish's comment array 

       $scope.dish.comments.push({ rating:$scope.feedback.stars,comment:$scope.feedback.comments, 
         author:$scope.feedback.Name,date:x}); 
       //Step 4: reset your form to pristine 

        $scope.feedback = {comments:"", Name:"", stars:"" }; 
        $scope.feedback.mychannel=""; 
        $scope.feedbackForm.$setPristine(); 

       //Step 5: reset your JavaScript object that holds your comment 
      } 
     }]) 

     .controller('FeedbackController', ['$scope', function($scope) { 

      $scope.sendFeedback = function() { 

       console.log($scope.feedback); 





      }; 
     }]) 


     .controller('DishDetailController', ['$scope', '$routeParams', 'menuFactory', function($scope, $routeParams, menuFactory) { 

      var dish= menuFactory.getDish(parseInt($routeParams.id,10));      
      $scope.dish = dish; 
      var dish={ 
          name:'Uthapizza', 
          image: 'uthapizza.png', 
          category: 'mains', 
          label:'Hot', 
          price:'4.99', 
          description:'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.', 
          comments: [ 
           { 
            rating:5, 
            comment:"Imagine all the eatables, living in conFusion!", 
            author:"John Lemon", 
            date:"2012-10-16T17:57:28.556094Z" 
           }, 
           { 
            rating:4, 
            comment:"Sends anyone to heaven, I wish I could get my mother-in-law to eat it!", 
            author:"Paul McVites", 
            date:"2014-09-05T17:57:28.556094Z" 
           }, 
           { 
            rating:3, 
            comment:"Eat it, just eat it!", 
            author:"Michael Jaikishan", 
            date:"2015-02-13T17:57:28.556094Z" 
           }, 
           { 
            rating:4, 
            comment:"Ultimate, Reaching for the stars!", 
            author:"Ringo Starry", 
            date:"2013-12-02T17:57:28.556094Z" 
           }, 
           { 
            rating:2, 
            comment:"It's your birthday, we're gonna party!", 
            author:"25 Cent", 
            date:"2011-12-02T17:57:28.556094Z" 
           } 

          ] 
        }; 

      $scope.dish = dish; 

     }]); 

Services.js

angular.module('confusionApp') 
     .service('menuFactory', function() { 
      var dishes=[ 
         { 
          _id:0, 
          name:'Uthapizza', 
          image: 'images/uthapizza.png', 
          category: 'mains', 
          label:'Hot', 
          price:'4.99', 
          description:'A unique combination of Indian Uthappam (pancake) and Italian pizza, topped with Cerignola olives, ripe vine cherry tomatoes, Vidalia onion, Guntur chillies and Buffalo Paneer.', 
          comments: [ 
           { 
            rating:5, 
            comment:"Imagine all the eatables, living in conFusion!", 
            author:"John Lemon", 
            date:"2012-10-16T17:57:28.556094Z" 
           }, 
           { 
            rating:4, 
            comment:"Sends anyone to heaven, I wish I could get my mother-in-law to eat it!", 
            author:"Paul McVites", 
            date:"2014-09-05T17:57:28.556094Z" 
           }, 
           { 
            rating:3, 
            comment:"Eat it, just eat it!", 
            author:"Michael Jaikishan", 
            date:"2015-02-13T17:57:28.556094Z" 
           }, 
           { 
            rating:4, 
            comment:"Ultimate, Reaching for the stars!", 
            author:"Ringo Starry", 
            date:"2013-12-02T17:57:28.556094Z" 
           }, 
           { 
            rating:2, 
            comment:"It's your birthday, we're gonna party!", 
            author:"25 Cent", 
            date:"2011-12-02T17:57:28.556094Z" 
           }               ] 
         }, 
         { 
          _id:1, 
          name:'Zucchipakoda', 
          image: 'images/zucchipakoda.png', 
          category: 'appetizer', 
          label:'', 
          price:'1.99', 
          description:'Deep fried Zucchini coated with mildly spiced Chickpea flour batter accompanied with a sweet-tangy tamarind sauce', 
          comments: [ 
           { 
            rating:5, 
            comment:"Imagine all the eatables, living in conFusion!", 
            author:"John Lemon", 
            date:"2012-10-16T17:57:28.556094Z" 
           }, 
           { 
            rating:4, 
            comment:"Sends anyone to heaven, I wish I could get my mother-in-law to eat it!", 
            author:"Paul McVites", 
            date:"2014-09-05T17:57:28.556094Z" 
           }, 
           { 
            rating:3, 
            comment:"Eat it, just eat it!", 
            author:"Michael Jaikishan", 
            date:"2015-02-13T17:57:28.556094Z" 
           }, 
           { 
            rating:4, 
            comment:"Ultimate, Reaching for the stars!", 
            author:"Ringo Starry", 
            date:"2013-12-02T17:57:28.556094Z" 
           }, 
           { 
            rating:2, 
            comment:"It's your birthday, we're gonna party!", 
            author:"25 Cent", 
            date:"2011-12-02T17:57:28.556094Z" 
           }               ] 
         }, 
         { 
          _id:2, 
          name:'Vadonut', 
          image: 'images/vadonut.png', 
          category: 'appetizer', 
          label:'New', 
          price:'1.99', 
          description:'A quintessential ConFusion experience, is it a vada or is it a donut?', 
          comments: [ 
           { 
            rating:5, 
            comment:"Imagine all the eatables, living in conFusion!", 
            author:"John Lemon", 
            date:"2012-10-16T17:57:28.556094Z" 
           }, 
           { 
            rating:4, 
            comment:"Sends anyone to heaven, I wish I could get my mother-in-law to eat it!", 
            author:"Paul McVites", 
            date:"2014-09-05T17:57:28.556094Z" 
           }, 
           { 
            rating:3, 
            comment:"Eat it, just eat it!", 
            author:"Michael Jaikishan", 
            date:"2015-02-13T17:57:28.556094Z" 
           }, 
           { 
            rating:4, 
            comment:"Ultimate, Reaching for the stars!", 
            author:"Ringo Starry", 
            date:"2013-12-02T17:57:28.556094Z" 
           }, 
           { 
            rating:2, 
            comment:"It's your birthday, we're gonna party!", 
            author:"25 Cent", 
            date:"2011-12-02T17:57:28.556094Z" 
           } 
                  ] 
         }, 
         { 
          _id:3, 
          name:'ElaiCheese Cake', 
          image: 'images/elaicheesecake.png', 
          category: 'dessert', 
          label:'', 
          price:'2.99', 
          description:'A delectable, semi-sweet New York Style Cheese Cake, with Graham cracker crust and spiced with Indian cardamoms', 
          comments: [ 
           { 
            rating:5, 
            comment:"Imagine all the eatables, living in conFusion!", 
            author:"John Lemon", 
            date:"2012-10-16T17:57:28.556094Z" 
           }, 
           { 
            rating:4, 
            comment:"Sends anyone to heaven, I wish I could get my mother-in-law to eat it!", 
            author:"Paul McVites", 
            date:"2014-09-05T17:57:28.556094Z" 
           }, 
           { 
            rating:3, 
            comment:"Eat it, just eat it!", 
            author:"Michael Jaikishan", 
            date:"2015-02-13T17:57:28.556094Z" 
           }, 
           { 
            rating:4, 
            comment:"Ultimate, Reaching for the stars!", 
            author:"Ringo Starry", 
            date:"2013-12-02T17:57:28.556094Z" 
           }, 
           { 
            rating:2, 
            comment:"It's your birthday, we're gonna party!", 
            author:"25 Cent", 
            date:"2011-12-02T17:57:28.556094Z" 
           }               ] 
         } 
         ]; 


          this.getDishes = function(){ 
             return dishes; 
            }; 
        this.getDish = function (index) { 
             return dishes[index]; 
       }; 


     }); 

app.js:

angular.module('confusionApp', ['ngRoute']) 
.config(function($routeProvider) { 
     $routeProvider 
      // route for the contactus page 
      .when('/contactus', { 
       templateUrl : 'contactus.html', 
       controller : 'ContactController' 
      }) 
      // route for the menu page 
      .when('/menu', { 
       templateUrl : 'menu.html', 
       controller : 'MenuController' 
      }) 
      // route for the dish details page 
      .when('/menu/:id', { 
       templateUrl : 'dishdetail.html', 
       controller : 'DishDetailController' 
      }) 
      .otherwise('/contactus'); 
    }); 

答えて

1

はとしてスクリプトを並べ替え:あなたのcontroller.js

<script src="scripts/app.js"></script> 
<script src="scripts/services.js"></script> 
<script src="scripts/controllers.js"></script> 

置き換える:

angular.module('confusionApp', []) 

を持つ:

angular.module('confusionApp') 
+0

これは、完全に感謝を働きました! – Zain

関連する問題