应用程序未加载任何错误消息都未显示在控制台

时间:2016-08-21 17:48:43

标签: angularjs

<!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 -->
    <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"  ng-controller="dishDetailController as dishCtrl">
               <ul class="media-list">
                    <li class="media" ng-repeat="dish in dishCtrl.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> 
                    </div>
                     <div ng-repeat="dish in dishCtrl.dishes" class="col-sm-8 col-sm-push-1">
                      <form class="form-inline">
                        <div class="form-group">
                          <label class="form-control-static" style="font-size:20px;">Customer Comments</label>
                        </div>
                        <div class="form-group">
                          <label>Sort by:</label>
                          <input type="text" class="form-control" ng-model="sort">
                        </div>
                      </form>
                      <blockquote ng-repeat="c in dish.comments | orderBy:sort">
                        <p>{{c.rating}}</p>
                        <p>{{c.comment}}</p>
                        <footer>{{c.author}} <cite title="Source Title">{{c.date | date : format : timezone}}</cite></footer>
                     </blockquote>
                        <form class="form-horizontal" name="userForm"  ng-submit="submitForm(userForm.$valid)" noValidate>
                          <div class="form-group" ng-class="{ 'has-error' : userForm.name.$invalid && !userForm.name.$pristine }">
                            <label class="col-sm-2 control-label">Your Name</label>
                            <div class="col-sm-10">
                              <input type="text" name="name" class="form-control" placeholder="Enter your name" ng-model="user.name" required>
                              <p ng-show="userForm.name.$invalid && !userForm.name.$pristine" class="help-block">You name is required.</p>
                            </div>
                          </div>
                          <div class="form-group">
                            <label class="col-sm-2 radio">Number of stars</label>
                            <div class="col-sm-10">
                              <label class="radio-inline">
                              <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1" ng-model="stars"> 1
                            </label>
                            <label class="radio-inline">
                              <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2" ng-model="stars"> 2
                            </label>
                            <label class="radio-inline">
                              <input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3" ng-model="stars"> 3
                            </label>
                              <label class="radio-inline">
                              <input type="radio" name="inlineRadioOptions" id="inlineRadio4" value="option4" ng-model="stars"> 4
                            </label>
                              <label class="radio-inline">
                              <input type="radio" name="inlineRadioOptions" id="inlineRadio4" value="option5" ng-model="stars"> 5
                            </label>
                             </div>
                          </div>
                          <div class="form-group"  ng-class="{ 'has-error' : userForm.comment.$invalid && !userForm.comment.$pristine }">
                            <label class="col-sm-2 control-label">Your Comments</label>
                            <div class="col-sm-10">
                              <textarea class="form-control" rows="3" name="comment" ng-model="user.comment" required></textarea>
                               <p ng-show="userForm.comment.$invalid && !userForm.comment.$pristine" class="help-block">You name is required.</p>
                            </div>
                          </div>
                          <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                              <button type="submit" class="btn btn-primary">Submit Comment</button>
                            </div>
                          </div>
                        </form>
                   </div>                          
                </li>
            </ul>
          </div>
        </div>
    <script src="../bower_components/angular/angular.min.js"></script>
      <script>
    (function(){
        var app = angular.module('confusionApp',[]);
          app.controller('dishDetailController',['$scope', function($scope) {

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

                              ]

                           }
                        ]
                         $scope.dishes = dishes;
                         $scope.stars= option5;
                          $scope.submitForm = function(isValid){
                          if(isValid){

                          }
                        };
                     }]);


      })();
    </script>``

</body>
</html>

我的应用程序没有加载。在调试中我能够看到控制器正在加载但ng-repeat没有加载。如果我正在删除应用程序正在加载的作用域对象。 有人可以告诉我解决方案。

1 个答案:

答案 0 :(得分:0)

您正在使用package com.vogella.android.retrofitstackoverflow; import android.util.Log; import retrofit2.Callback; import retrofit2.http.GET; import retrofit2.http.Query; import retrofit2.Call; import rx.Observable; public interface StackOverflowAPI { @GET("/2.2/questions?order=desc&sort=creation&site=stackoverflow") //Call<StackOverflowQuestions> loadQuestions(@Query("tagged") String tags); Observable<StackOverflowQuestions> loadQuestions(@Query("tagged") String tags); } 语法并仍尝试通过范围访问您的数据。在您的情况下,使用controller as语法使用'别名'DishCtrl实例化您的控制器。

在控制器中,不要在作用域上设置controller as属性,而是将其作为控制器实例上的属性。

有些事情:

dishes;

var vm = this