mirror of
https://github.com/apache/struts.git
synced 2026-08-07 07:37:20 +00:00
Adjust archetype to API changes of AngularJS version 1.2.x
This commit is contained in:
+4
-3
@@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<%@ page contentType="text/html; charset=UTF-8" %>
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
<html lang="en" ng-app="angularstruts">
|
||||
<html lang="en" ng-app="angularStrutsApp">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>My AngularJS Struts2 App</title>
|
||||
@@ -15,12 +15,13 @@
|
||||
</div>
|
||||
|
||||
<div ng-controller="AppController">
|
||||
<div ng-view></div>
|
||||
<div ng-view></div>
|
||||
</div>
|
||||
|
||||
<script src="<s:url value="js/lib/angular/angular.min.js" />"></script>
|
||||
<script src="<s:url value="js/lib/angular/angular-route.min.js" />"></script>
|
||||
<script src="<s:url value="js/bootstrap.js" />"></script>
|
||||
<script src="<s:url value="js/directives.js" />"></script>
|
||||
<script src="<s:url value="js/controllers.js" />"></script>
|
||||
<script src="<s:url value="js/bootstrap.js" />"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+13
-12
@@ -18,16 +18,17 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
angular.module('angularstruts', [], function ($routeProvider) {
|
||||
$routeProvider.when('/projects', {
|
||||
templateUrl: '/partials/projects.html',
|
||||
controller: ApacheProjectsController
|
||||
}).when('/home', {
|
||||
templateUrl: '/partials/home.html',
|
||||
controller: HomeController
|
||||
}).otherwise({ redirectTo: '/home' });
|
||||
});
|
||||
|
||||
angular.element(document).ready(function () {
|
||||
angular.bootstrap(document, ['angularstruts']);
|
||||
});
|
||||
var angularStrutsApp = angular.module('angularStrutsApp', ['ngRoute']);
|
||||
|
||||
angularStrutsApp.config(['$routeProvider',
|
||||
function($routeProvider) {
|
||||
$routeProvider.when('/projects', {
|
||||
templateUrl: '/partials/projects.html',
|
||||
controller: 'ApacheProjectsController'
|
||||
}).when('/home', {
|
||||
templateUrl: '/partials/home.html',
|
||||
controller: 'HomeController'
|
||||
}).otherwise({ redirectTo: '/home' });
|
||||
}
|
||||
]);
|
||||
|
||||
+11
-14
@@ -18,25 +18,22 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
function AppController($scope) { }
|
||||
AppController.$inject = ['$scope'];
|
||||
angularStrutsApp.controller('AppController', function ($scope) { });
|
||||
|
||||
function HomeController($scope) {
|
||||
angularStrutsApp.controller('HomeController', function ($scope) {
|
||||
$scope.name = "Sunshine";
|
||||
}
|
||||
HomeController.$inject = ['$scope'];
|
||||
});
|
||||
|
||||
function ApacheProjectsController($scope, $http) {
|
||||
angularStrutsApp.controller('ApacheProjectsController', function ($scope, $http) {
|
||||
this.init = function() {
|
||||
$http({method: 'GET', url: '/projects'}).
|
||||
success(function(data) {
|
||||
$scope.projects = data.projectNames;
|
||||
}).
|
||||
error(function(data, status, headers, config) {
|
||||
alert("Could not receive project names");
|
||||
});
|
||||
success(function(data) {
|
||||
$scope.projects = data.projectNames;
|
||||
}).
|
||||
error(function(data, status, headers, config) {
|
||||
alert("Could not receive project names");
|
||||
});
|
||||
};
|
||||
|
||||
this.init();
|
||||
}
|
||||
ApacheProjectsController.$inject = ['$scope', '$http'];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user