Skip to content

Instantly share code, notes, and snippets.

@jbrackett
Created February 10, 2014 02:30
Show Gist options
  • Save jbrackett/8909382 to your computer and use it in GitHub Desktop.
Save jbrackett/8909382 to your computer and use it in GitHub Desktop.
HelloWorldSpring4View
/*jshint unused: false */
/*global angular:true */
// Declare app level module
var App = angular.module('App', []);
(function() {
'use strict';
App.controller("HelloCtrl", ['$scope', '$http',
function($scope, $http) {
$scope.name = "User";
$scope.message = "";
$scope.getName = function() {
$http.get('hello/' + $scope.name).then(function(response) {
$scope.message = "Hello " + response.data;
});
};
}
]);
})();
<!DOCTYPE html>
<html ng-app="App">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello</title>
</head>
<body ng-controller="HelloCtrl">
<input type="text" ng-model="name"></input><button ng-click="getName()">Submit</button>
<div>{{message}}</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.js"></script>
<script src="js/app.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment