2017-01-03 165 views
1

當我在命令行終端中運行gulp時,出現此警告。 我在HTML代碼中添加了angular.js文件。我無法弄清楚這個問題。未定義角度

HTML代碼:

<!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: Menu</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> 

    <div class="container"> 
     <div class="row row-content" ng-controller="menuController as menuCtrl"> 
      <div class="col-xs-12"> 
       <ul class="nav nav-tabs" role="tablist"> 
       <li role="presentation"> 
        <a aria-controls="all menu" role="tab" ng-click="menuCtrl.select(1)" ng-class="{active:menuCtrl.isSelected(1)}">The Menu</a></li> 

       <li role="presentation"> 
        <a aria-controls="appetizer" role="tab" ng-click="menuCtrl.select(2)" ng-class="{active:menuCtrl.isSelected(2)}">Appetizers</a></li> 

       <li role="presentation"> 
        <a aria-controls="mains" role="tab" ng-click="menuCtrl.select(3)" ng-class="{active:menuCtrl.isSelected(3)}">Mains</a></li> 

       <li role="presentation"> 
        <a aria-controls="desserts" role="tab" ng-click="menuCtrl.select(4)" ng-class="{active:menuCtrl.isSelected(4)}">Desserts</a></li> 


       </ul> 

       <div class="tab-content"> 
       <ul class="media-list tab-pane fade in active"> 
       <li class="media" ng-repeat="dish in menuCtrl.dishes | filter:menuCtrl.filtText"> 
        <div class="media-left media-middle"> 
        <a href="#"><img ng-src={{dish.image}} class="media-object img-thumbnail" alt="Uthappizza"></a> 
        </div> 
        <div class="media-body"> 
        <h2 class="media-heading">{{dish.name}}</h2> 
         <span class="label label-danger label-xs">{{dish.label}}</span> 
         <span class="badge">{{dish.price | currency}}</span> 
         <p>{{dish.description}}</p> 

        </div> 

       </li> 
      </ul> 
        </div> 
      </div> 
     </div> 
    </div> 

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


</body> 

</html>` 

app.js文件如下:

/*jslint node: true */ 
'use strict'; 

angular.module('confusionApp',[]) 

     .controller('menuController',function(){ 

             this.tab=1; 
             this.filtText=""; 


             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.', 
               comment: '' 

               }, 
               { 

               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', 
               comment: '' 

               }, 
               { 

               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?', 
               comment: '' 

               }, 
               { 
               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', 
               comment: '' 

               } 
               ]; 
            this.dishes=dishes; 


            this.select=function(settab){ 

             this.tab=settab; 

             if(settab===2){ 
              this.filtText="appetizer"; 
             } 
             else if(settab===3){ 
              this.filtText="mains"; 
             } 
             else if(settab===4){ 
              this.filtText="dessert"; 
             } 
             else{ 
              this.filtText=""; 
             } 
            }; 

            this.isSelected=function(checktab){ 

             return(this.tab===checktab); 
            }; 



     }); 

`

this is the error when I run gulp in command line prompt

+0

在其他腳本頂部調用'angular'腳本 –

+0

哪個gulp任務報告了錯誤?是eslint還是其他靜態檢查? –

+0

這只是一個吞嚥警告。你的app.js文件不知道變量'angular'。你可以忽略警告,或配置吞嚥,所以它知道的角 – devqon

回答

0

將您AngularJs從BODY文件裏面HEAD標籤。它會正常工作。

+0

我試過這個,但它沒有工作 – Radhika

+0

你是如何安裝所有這些_bower_components_?通過_bower install_或者您剛剛從網站下載它? – 2017-01-03 11:57:41

+0

我使用了bower安裝 - 所有的組件都在bower文件夾中 – Radhika

0

Yor錯誤顯示在第5行,但您的原始文件顯示 角度參考某些不同的行。 (i)嘗試再次運行應用程序。 (ii)如果角度參考正確加載,請檢查鍍鉻中的網絡選項卡。

如果不改變路徑是正確的,再次做測試。

-1

角需要jQuery的,可能要包括藏漢如。

<script 
    src="https://code.jquery.com/jquery-3.1.1.min.js" 
    integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" 
    crossorigin="anonymous"></script> 

請確保您有它,你包括角文件

+0

沒有工作。感謝您的幫助 – Radhika

0

我在app.js刪除「使用嚴格的」後嘗試過文件,它爲我工作。