Skip to content

Instantly share code, notes, and snippets.

@crised
Last active August 29, 2015 14:06
Show Gist options
  • Save crised/39c75cd8bb51fcc6f6dc to your computer and use it in GitHub Desktop.
Save crised/39c75cd8bb51fcc6f6dc to your computer and use it in GitHub Desktop.
'use strict';
/**
* @ngdoc function
* @name angApp.controller:AboutCtrl
* @description
* # AboutCtrl
* Controller of the angApp
*/
angular.module('angApp')
.controller('AboutCtrl', function ($scope, $http) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma'
];
$scope.x = sum(5,2);
$scope.y = 16;
$scope.increment = function(){
$scope.y++;
$scope.x++;
}
$scope.send = function(){
$http.post('http://localhost:1337', '2').then(successFn(),failFn());
}
});
//angular.module('mymodule').controller('sendController', function($http){
//})
function sum(p1, p2) {
return p1 + p2; // the function returns the product of p1 and p2
}
function failFn(){
console.log('POST failed');
}
function successFn(){
console.log('POST sent');
}
---------
about.html
<p>This is the about view.</p>
Write some text in textbox:
<input type="text" ng-model="y" />
<button ng-click="increment()" type="button">Increment!</button>
<button ng-click="send()" type="button">Send!</button>
<h1>{{x}} {{y}}</h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment