-
-
Save tarlepp/44414082b48ccc1f0c75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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