显示空白页-Angular JS

Zain

控制台未显示任何错误,但页面未显示任何内容。这是我的代码。

该代码基本上包含一个角度模块和一个控制器。我尝试在不包含angular.js脚本文件的情况下运行代码,页面显示是预期的,因为它仅输出Html组件。但是,在包含Angular JS组件之后,该页面将产生干净的外观。

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

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

    <!-- 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">
            <div class="col-xs-12">
            <ul>
            <li class="media" ng-repeat="dish in myctrl.dishes">
                    <div class="media-left media-middle">
                        <a href="#">
                        <img class="media-object img-thumbnail"
                         ng-src={{dish.image}} alt="Uthappizza">
                        </a>
                    </div>
                    <div class="media-body">
                        <h2 class="media-heading">{{dish.name}}
                         <span class="label label-danger">{{dish.label}}</span>
                         <span class="badge">{{dish.price | currency}}</span></h2>
                          <p>{{dish.description}}</p>
                        <p>Comment: {{dish.comment}}</p>
                        <p>Type your comment:
                         <input type="text" ng-model="dish.comment"></p>
                    </div>
                </li>
                </ul>
            </div>
            </div>
        </div>

<script src="bower_components/angular/angular.min.js"></script>
<script>
        var app = angular.module('myApp',[]);
       app.controller('myctrl',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.',
                           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;

        });

    </script>
</body>

</html>
斯里吉斯

您需要添加ng-controller在你的div下面的body

<body>
 <div ng-controller="myctrl as myctrl">
  <REST OF YOUR HTML>
 </div>
</body>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Heroku上的空白页-Mean.js angular应用程序

来自分类Dev

fabric.js-当画布上有图像时,toDataURL显示空白页

来自分类Dev

IE11显示空白页

来自分类Dev

Facebook应用画布显示空白页

来自分类Dev

Ember JS应用显示空白页

来自分类Dev

使用angular.js路由空白页

来自分类Dev

ng-repeat返回空白页[Angular]

来自分类Dev

PHP!_GET显示空白页

来自分类Dev

sails.js-获取空白页

来自分类Dev

加载less.min.js CDN导致空白页

来自分类Dev

Angular js应用程序在ios浏览器,Safari和chrome上都显示空白页面。在Windows桌面浏览器上工作正常

来自分类Dev

ubuntu man命令显示空白页

来自分类Dev

Tensorboard显示空白页(拒绝执行“ http:// localhost:6006 / index.js”中的脚本,因为它的MIME类型)

来自分类Dev

UseStatusCodePagesWithReExecute显示空白页

来自分类Dev

已部署Firebase React.js应用-空白页

来自分类Dev

灵活的列布局显示空白页

来自分类Dev

ubuntu man命令显示空白页

来自分类Dev

fabric.js-当画布上有图像时,toDataURL显示空白页

来自分类Dev

Raphael JavaScript显示空白页

来自分类Dev

Ember JS应用显示空白页

来自分类Dev

Ember JS应用显示空白页

来自分类Dev

Heroku上的空白页-Mean.js Angular应用

来自分类Dev

PHP文件显示空白页

来自分类Dev

javascript空白页显示

来自分类Dev

Hawtio显示空白页

来自分类Dev

使用angular.js路由空白页

来自分类Dev

Webmatrix显示空白页

来自分类Dev

AMP页显示空白页

来自分类Dev

为什么我的 Angular 路由教程的后续代码显示空白页?