1

I am using angularjs in my application. I have a problem with this code, this code generate data first time. But when I come back to that page from other location it give only expression written in jsp page

Below is my 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']);
});

It gives expression when I reload the page from other location like this

{{question.title}}

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

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

I analyzed that page is not loading again. Means document.ready is not calling again on that page. Could anyone please help how to call again the module written in app.js without using document.ready.

Any help would be appreciated. Thanks in advance.

4
  • possible duplicate of Angular js is controller not loading Commented Dec 4, 2014 at 9:56
  • You cannot just post the question again after less than a day when you feel like people are not answering your previous post. Flagged as duplicate of your previous same question. Commented Dec 4, 2014 at 9:56
  • Are there any errors in your console? Also, show your HTML? And, why are you manually bootstrapping your code? Commented Dec 4, 2014 at 20:33
  • The error in console is Error: [ng:btstrpd] errors.angularjs.org/1.2.26/ng/btstrpd?p0=document Commented Dec 5, 2014 at 11:36

1 Answer 1

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>

And if I do not bootstrap my code manually on document.ready page does not load angular js not even first time.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.