2016-06-15 9 views
0

私はそれが愚かな質問であることを知っています。私の角度のある工場が私のページで働かなくなったことを知らない。以前はスクリプト全体が1つのファイルだったが、後で作業していたときとは違うファイルに分割した。は角度のあるファクトリメソッドでは機能しません

私のファイルはここにある。

がapp.js

'use strict'; 

angular.module('confusionApp', []); 

controller.js

'use strict'; 

angular.module('confusionApp') 

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

      $scope.tab = 1; 
      $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 = {mychannel:"", firstName:"", lastName:"", agree:false, email:"" }; 

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

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

     }]) 

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

      $scope.sendFeedback = function() { 

       console.log($scope.feedback); 

       if ($scope.feedback.agree && ($scope.feedback.mychannel == "")) { 
        $scope.invalidChannelSelection = true; 
        console.log('incorrect'); 
       } 
       else { 
        $scope.invalidChannelSelection = false; 
        $scope.feedback = {mychannel:"", firstName:"", lastName:"", agree:false, email:"" }; 
        $scope.feedback.mychannel=""; 
        $scope.feedbackForm.$setPristine(); 
        console.log($scope.feedback); 
       } 
      }; 
     }]) 

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

      $scope.dish= menuFactory.getDish(3); 

     }]) 

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

      //Step 1: Create a JavaScript object to hold the comment from the form 
      var stars=[{value:"1" 
         }, 
         { 
         value:"2" 
         }, 
         { 
         value:"3" 
         }, 
         { 
         value:"4" 
         }, 
         { 
          value:"5" 

         } 

         ]; 

      $scope.isSelected=function(checkStar){ 
       console.log(checkStar==5); 
       return checkStar==5; 
      }; 

      $scope.stars=stars; 

      $scope.comment={name:"",rating:"5",textComments:"",date:""}; 

      $scope.submitComment = function() { 

           $scope.comment.date=new Date().toISOString(); 

      } 
     }]) 

; 

service.js

'use strict'; 

angular.module('confusionApp'){ 
    .factory('menuFactory',function(){ 

      var dishes=[ 
         { 
          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" 
           }               ] 
         }, 
         { 
          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" 
           }               ] 
         }, 
         { 
          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" 
           } 
                  ] 
         }, 
         { 
          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" 
           }               ] 
         } 
         ]; 
     var menufac = {}; 
     menufac.getDishes = function(){ 
             return dishes; 
            }; 
        menufac.getDish = function (index) { 
             return dishes[index]; 
       }; 
       return menufac; 
    } 
); 

は、ここでは配列の私の順だ

<script src="../app/scripts/app.js"></script> 
<script src="../app/scripts/controller.js"></script> 
<script src="../app/scripts/service.js"></script> 

私はそれほど難しくないが、わかりません

+0

あなたのHTMLにスクリプトがリストされている順序を表示できますか? – Claies

答えて

2

おそらくコンパイルエラーにつながる余分なブレースが3行目にあります。多分あなたのバグです。そうでない場合は、質問を編集してください。

'use strict'; 

angular.module('confusionApp'){ 
    .factory('menuFactory',function(){ 
... 
+0

私は馬鹿だ。ありがとう – LowCool

関連する問題