click事件不使用angular JS和Require JS

时间:2016-04-11 04:01:19

标签: angularjs requirejs

我正在开发一个应用程序,我正在尝试使用require JS加载角度JS。我的点击事件在我的代码中不起作用。有人可以帮忙:

<!DOCTYPE html>
<html lang="en" data-ng-app="myApp">

    <body class="internal" >
        <div id="contentContainer" class="stratum" data-ng-controller="appController">
                <div id="main-bar" class="row">                 
                    <div id="go" class="column column.one-quarter-">
                            <div class="btnLabel"><label for="submitBtn"></label></div>
                            <div><button id="submitBtn" ng-click="getBarChartData()"> GO</button></div>
                    </div>

                </div>
        </div>
    </body>
    <script type="text/javascript">
            var contextPath = "<%= request.getContextPath() %>";
            var appUrl = "<%= request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() %>";
            var isSessionExpired = false; 
        </script> 
        <!-- JavaScripts Require JS Library and App JS Files -->
        <script type="text/javascript" data-main="<%=request.getContextPath() %>/resources/js/app/uptimeReport.js" src="<%=request.getContextPath() %>/resources/js/libs/requirejs/require.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath() %>/resources/js/app/main-built.js"></script>    
</body>
</html>

App.js

/*global require*/
'use strict';

require([
    'angular'
], function (angular) {
    require([
        'controller/environmentController'

    ], function (appCtrl) {
        angular.
        module('myApp',[]).
        controller('appController', appCtrl);
        angular.bootstrap(document, ['myApp']);         
        console.log("in App.js");
    }); 
});

uptimeReport.js

/*global require*/
'use strict';

requirejs.config(
{
    /** set up any additional paths that are outside of your application base * */
    paths:
    {
        angular: contextPath + '/resources/js/libs/angularJS/angular',
    },
    /**
     * The following is not required in this example, but it is an example of
     * how to make non-AMD java script compatible with require
     */
    shim: {
        angular: {
            exports: 'angular'
        }
    },
    deps: ['app']
});

控制器/ environmentController.js

/*global define*/
'use strict';

/**
 * The main controller for the app. The controller:
 * - retrieves and persist the model via the todoStorage service
 * - exposes the model to the template and provides event handlers
 */

define([
    'angular'
], function (angular) {
    return ['$scope', '$http',
            function($scope, $http) {
        console.log("in controller123.js");
           var businessUrl="http://localhost:8080/UptimeReport/services/getBusinessAreas";
           var appUrl="http://localhost:8080/UptimeReport/services/getApplications";
           var envUrl="http://localhost:8080/UptimeReport/services/getEnvironments";
                $http.get(businessUrl).then(function(response) {
                $scope.business = response.data;
                 });
                 $http.get(appUrl).then(function(response) {
                $scope.application = response.data;
                 });
                  $http.get(envUrl).then(function(response) {
                $scope.environment = response.data;
                 });

        }];

    });

0 个答案:

没有答案