Angularjs没有第二次加载

时间:2014-12-04 09:39:06

标签: javascript jquery angularjs

我在我的应用程序中使用angularjs。我的代码有问题,这段代码第一次生成数据。但是当我从其他位置回到那个页面时,它只给出了用jsp页面写的表达式

以下是我的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未在该页面上再次调用。任何人都可以帮助如何再次调用app.js中编写的模块,而无需使用document.ready。

任何帮助将不胜感激。 提前谢谢。

1 个答案:

答案 0 :(得分: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。

相关问题