eventman/angular_app/js/app.js

60 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-03-22 08:57:57 +01:00
'use strict';
2015-03-22 09:19:30 +01:00
/* Register our fantastic module. */
2015-03-15 18:00:08 +01:00
var eventManApp = angular.module('eventManApp', [
2015-03-21 15:45:40 +01:00
'ngRoute',
'eventManServices',
'eventManControllers'
2015-03-15 18:00:08 +01:00
]);
2015-03-21 15:45:40 +01:00
2015-03-22 09:19:30 +01:00
/* Directive that can be used to make an input field react to the press of Enter. */
2015-03-21 15:33:17 +01:00
eventManApp.directive('ngEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if(event.which === 13) {
scope.$apply(function (){
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
});
};
});
2015-03-21 15:45:40 +01:00
2015-03-22 09:19:30 +01:00
/* Configure the routes. */
2015-03-15 18:00:08 +01:00
eventManApp.config(['$routeProvider',
2015-03-21 15:45:40 +01:00
function($routeProvider) {
$routeProvider.
when('/persons', {
templateUrl: 'persons-list.html',
controller: 'PersonsListCtrl'
}).
when('/persons/:id', {
templateUrl: 'person-detail.html',
controller: 'PersonDetailsCtrl'
}).
when('/events', {
templateUrl: 'events-list.html',
controller: 'EventsListCtrl'
}).
when('/events/:id', {
templateUrl: 'event-detail.html',
controller: 'EventDetailsCtrl'
}).
when('/new-event', {
templateUrl: 'event-detail.html',
controller: 'EventDetailsCtrl'
}).
when('/new-person', {
templateUrl: 'person-detail.html',
controller: 'PersonDetailsCtrl'
}).
otherwise({
redirectTo: '/events'
});
2015-03-22 09:19:30 +01:00
}
]);
2015-03-15 18:00:08 +01:00