-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
31 lines (25 loc) · 809 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(function() {
'use strict';
var app = angular.module('myapp', ['angular-api', 'plugin-alert']);
app.controller('MainCtrl', ['$scope', '$log', 'Api', function ($scope, $log, Api) {
var submitForm = function(message) {
$log.info($scope.message);
$scope.api.form.raise.submitted(message);
};
var clearForm = function(message) {
$scope.message = '';
$scope.api.form.raise.cleared();
};
$scope.submit = function($event) {
submitForm($scope.message);
};
$scope.clear = function($event) {
clearForm();
};
$scope.api = new Api(this, $scope.$id);
$scope.api.registerEvent('form', 'submitted');
$scope.api.registerMethod('form', 'submit', submitForm);
$scope.api.registerEvent('form', 'cleared');
$scope.api.registerMethod('form', 'clear', clearForm);
}]);
})();