2014-12-04 64 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。

相关问题