控制器在与视图相同的文件中未定义

时间:2016-03-08 00:46:49

标签: angularjs

我能够为userForm.html呈现视图,但我一直收到错误消息:

 SchematronOutputType outputType = SchematronUtil.validateXMLViaXSLTSchematronFull(schematronFile, xmlFile);

            if (outputType == null){
                throw new Exception("SchematronOutputType null");
            }

            List<SVRLSuccessfulReport> succeededList = SVRLHelper.getAllSuccessfulReports(outputType);
            for (SVRLSuccessfulReport succeededReport : succeededList){
                System.out.println(succeededReport.getTest());
            }

            int i = 1;
            List<SVRLFailedAssert> failedList = SVRLHelper.getAllFailedAssertions(outputType);
            for (SVRLFailedAssert failedAssert : failedList) {
                System.out.println(i++ + ". Location:" + failedAssert.getLocation());
                System.out.println("Test: " + failedAssert.getTest());
                System.out.println("Text: " + failedAssert.getText());

                List<DiagnosticReference> diagnisticReferences = failedAssert.getDiagnisticReferences();
                for (DiagnosticReference diagnisticRef : diagnisticReferences) {
                    System.out.println("Diag ref: " + diagnisticRef.getDiagnostic());
                    System.out.println("Diag text: " + diagnisticRef.getText());
                }
            }

            if (failedList.isEmpty()){
                System.out.println("PASS");
            }
            else{
                System.out.println("FAIL");
            }

有问题的控制器是userFormController,就像上面的错误显示一样。

userFormController

angular.js:12722 Error: [ng:areq] Argument 'userFormController' is not a function, got undefined

configuration.js

angular.module('myApp')
    .controller('userFormController',['$scope', function($scope){
        console.log('You are in the userFormController');
}]);

的index.html

angular.module('myApp').
config(function($routeProvider) {
    $routeProvider.when('/',{
        templateUrl: "pages/mainPage/mainPage.html",
        controller:"mainPageController"
    })
        .when('/userForm',{
           templateUrl: 'pages/userForm/userForm.html',
           controller: 'userFormController'
        })
        .when('',{
            templateUrl:'',
            controller:''
        })
    .otherwise({redirectTo:'/'});

});

mainPage.html

<body ng-app="myApp">

  <!--[if lt IE 7]>
      <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  <![endif]-->

  <div ng-view></div>

  <div>Angular seed app: v<span app-version></span></div>

  <!-- In production use:
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
  -->
  <script src="bower_components/angular/angular.js"></script>
  <script src="bower_components/angular-route/angular-route.js"></script>
  <script src="app.js"></script>
  <script src="components/version/version.js"></script>
  <script src="components/version/version-directive.js"></script>
  <script src="components/version/interpolate-filter.js"></script>
  <script src="pages/mainPage/mainPageController.js"></script>
  <script src="configuration.js"></script>
</body>
</html>

enter image description here

2 个答案:

答案 0 :(得分:0)

脚本标记中的userFormController.js在哪里?

答案 1 :(得分:0)

您需要在index.html中包含userFormController.js文件,如下所示:

HANDLE_MSG(hWnd, WM_COMMAND, OnCommand);