Angular js是控制器未加载

时间:2014-12-03 14:26:11

标签: angularjs

我使用AngularJS加载了一个页面。我有以下代码:

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

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

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

当我们使用AngularJS在当前会话中第二次加载页面时,它不会加载。它只给出在jsp页面上写的表达式,例如:

{{question.title}}
{{cell.f}}{{cell.f}}
{{row.h}} {{row.v}} {{row.v}}

1 个答案:

答案 0 :(得分:1)

在成功回调后删除};

app.controller(
        "ReportController",
        function ($scope,$http) {

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

    );