2016-06-16 1 views
1

ここで私は同じことについて多くの質問をチェックしましたが、運がない。私は単純にng-includeをHTMLページに含めていますが、そのページを自分のコードに追加していません。ng-includes角を含むページを含まない

<!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> 


    <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-include src="'contactUs.html'"></div>--> 
<script type="text/ng-template" id="contactUs.html"> 

<footer class="row-footer"> 

    </footer> 

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

</body> 

</html> 

はここに私のapp.jsだ。この私のindex.html

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(parseInt($routeParams.id,10)); 

     }]) 

     .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() { 



      } 
     }]) 

; 

service.js

'use strict'; 

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]; 
       }; 

    } 
); 
+0

のようなソースの完全なパスを与える必要がありますが、サーバー上でアプリケーションを実行していますか?または単に静的ページですか? – gaurav5430

+0

通常の静的ページ –

答えて

0

ng-includeは、一部のブラウザが原因Cross Origin問題や原因file://プロトコルにロードからテンプレートを制限するだろうとして、あなたのアプリケーションを提供するWebサーバなしで動作しないでしょう。ドキュメントを1として

また、ブラウザの同一生成元ポリシーとクロスオリジン リソースの共有(CORS)政策がさらに テンプレートが正常にロードされているかどうかを制限することができます。たとえば、すべてのブラウザで ドメイン間リクエスト、一部の ブラウザでfile://アクセスでngIncludeが機能しません。また

、見て: Is it possible to use ng-include without web server?

TL; DRは - ウェブサーバなしで動作しないNG-含まれています。

P.S:私はあなたのディレクトリ構造についてはよく分からないのですが、

<script type="text/ng-template" id="sample.html"> 
    <div>This is my sample template</div> 
</script> 
+0

Oohh、。説明のためにありがとう。とにかく私はちょうど私のテンプレートとチェックを含めることができますか? –

+0

答えの終わりに向かって、私は方法を言及している、あなたもリンクを見てみることができる – gaurav5430

+0

私はgotSCRIPT5022よりもIDとしてページを追加しました:[$ injector:modulerr] http://errors.angularjs.org/1.4.11/$ injector/modulerr? –

0

:リンクに述べたように、回避策がある、あなたが使用して同じHTMLファイルにテンプレートを含めることができます。したがって、あなたのcontactUs.htmlをフォルダ内の同じレベルに置くか、srcに完全なパスを与えてください。例えば

- index.htmlを

- ContuctUs.htmlその後、

<ng-include src="'contactUs.html'"></ng-include> 

が動作する罰金

しかし、あなたのページには、

のようないくつかの他のパス上にある場合

- index。HTML

- ビューこのシナリオで

-- contctUs.html 

あなたは

<ng-include src="'view/contactUs.html'"></ng-include> 
+0

その同じフォルダに –

関連する問題