2014-12-04 90 views
1

我在我的應用程序中使用了angularjs。我有這個代碼的問題,這段代碼第一次生成數據。但是,當我回來從其他位置該網頁時只給寫在jsp頁面中表達Angularjs不是第二次加載

下面是我的app.js

var app = angular.module("myModule",[]); 
app.controller(
     "ReportController", 
     function ($scope,$http) { 

      $http({ 
       method: 'POST', 
       url: 'mypage_body.do', 
       data: 'action=fetchdata', 
       headers: {'Content-Type': 'application/x-www-form-urlencoded'} 
      }) 
      .success(function(response) { 
       $scope.questions = response; 
       }); 
      } 
    ); 

angular.element(document).ready(function(){ 
    angular.bootstrap(document,['myModule']); 
}); 

它給表達,當我重新加載頁面從其他位置 這樣

{{question.title}} 

{{cell.f}}{{cell.f}} 

{{row.h}} {{row.v}} {{row.v}} 

我分析過這個頁面沒有再次加載。意味着document.ready不會再在該頁面上調用。任何人都可以請幫助如何在不使用document.ready的情況下再次調用寫在app.js中的模塊。

任何幫助,將不勝感激。 在此先感謝。

+0

可能的重複的[角js是控制器不加載](http://stackoverflow.com/questions/27274167/angular-js-is-controller-not-loading) – Blackunknown 2014-12-04 09:56:06

+0

你不能只是發佈後的問題再次少於一天,當你覺得人們沒有回答你以前的帖子。標記爲您之前相同問題的副本。 – Blackunknown 2014-12-04 09:56:48

+0

控制檯中是否有任何錯誤?另外,顯示你的HTML?而且,爲什麼你手動引導你的代碼? – SoluableNonagon 2014-12-04 20:33:51

回答

0
<script type="text/javascript" src="/campustoolshighered/css/js/angular-1.2.26.min.js"></script> 
<script type="text/javascript" src="/campustoolshighered/css/js/adhocreport/app.js"></script> 
<script type="text/javascript" src="/campustoolshighered/css/uiframework/js/bootstrap.js"></script> 

<div ng-controller="ReportController"> 
          <div class="row" ng-repeat="question in questions"> 
             <div class="col-md-12"> 
              <div class="module"> 
               <div class="heading"> 
                <h2>{{question.title}}</h2> 
                <div class="module-options"> 
                 <span tabindex="3" class="icon-settings pop" title="Edit" data-toggle="tooltip" data-popoverid="#icon-setting"><span class="sr-only">Widget settings</span></span> 
                </div> 
               </div> 
               <div class="module-content" > 
                <div class="row"> 
                 <div class="col-md-12"> 
                  <div class="table-wrap"> 
                   <table class="table table-striped"> 
                    <thead> 
                     <tr> 
                      <th scope="col" role="columnheader" ng-repeat="header in question.dataTable.cols" >{{header.label}}</th>                    
                     </tr> 
                    </thead> 
                    <tbody> 
                     <tr ng-repeat="row in question.dataTable.rows"> 
                      <td ng-repeat="cell in row.cells"><a ng-if="cell.link" href="{{cell.link}}" tabindex="3">{{cell.f}}</a><span ng-if="!cell.link">{{cell.f}}</span></td> 

                     </tr>                   
                    </tbody> 
                   </table> 
                  </div> 
                  <ul ng-show="question.aggregateTable"> 
                   <li ng-repeat="row in question.aggregateTable.rows"> 
                   <strong>{{row.h}} </strong> 
                   <a ng-if="row.link" href="{{row.link}}" tabindex="3">{{row.v}}</a> 
                   <span ng-if="!row.link">{{row.v}}</span> 
                   </li>                 
                  </ul> 
                 </div> 
                </div> 
               </div> 
              </div> 
             </div> 
            </div> 
          </div> 

如果我沒有在document.ready頁面上手動引導我的代碼,則不會首次加載角度js。