Adjust archetype to API changes of AngularJS version 1.2.x

This commit is contained in:
Johannes Geppert
2014-08-31 13:54:33 +02:00
parent 387f8027fd
commit a16cedb26e
3 changed files with 28 additions and 29 deletions
@@ -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>
@@ -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' });
}
]);
@@ -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'];
});