mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-10 23:46:49 +02:00
First Commit
This commit is contained in:
commit
2630cc237a
527 changed files with 104273 additions and 0 deletions
65
public/js/controllers/newevent.controller.js
Normal file
65
public/js/controllers/newevent.controller.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
angular.module('rallly')
|
||||
.controller('NewEventCtrl', function($scope, $http, $state){
|
||||
$scope.event = {};
|
||||
$scope.templates = {
|
||||
modal : 'templates/modal.html'
|
||||
};
|
||||
$scope.submit = function(){
|
||||
$http.post('/api/event', $scope.event)
|
||||
.success(function(event, status, headers, config){
|
||||
$scope.event = event;
|
||||
$scope.eventUrl = $state.href('event', {
|
||||
id: $scope.event._id
|
||||
}, {
|
||||
absolute : true
|
||||
});
|
||||
// $state.go('event',{id : data.event._id});
|
||||
})
|
||||
.error(function(data, status, headers, config){
|
||||
$scope.errors = data.errors;
|
||||
console.log(data.errors);
|
||||
})
|
||||
}
|
||||
$scope.clearDates = null
|
||||
})
|
||||
.directive('datepicker', function(){
|
||||
return {
|
||||
restrict : 'A',
|
||||
require : 'ngModel',
|
||||
link : function(scope, el, attrs, ngModel){
|
||||
$(el).datepicker({
|
||||
multidate : true,
|
||||
todayHighlight: true,
|
||||
format : 'dd/mm/yyyy'
|
||||
})
|
||||
.on('changeDate', function(e){
|
||||
var dates = e.dates;
|
||||
dates.sort(function(a, b){
|
||||
if (a.getTime() > b.getTime()) return true;
|
||||
return false;
|
||||
});
|
||||
ngModel.$setViewValue(dates, e);
|
||||
});
|
||||
|
||||
scope.clearDates = function(){
|
||||
$(el).datepicker('setDate', null)
|
||||
};
|
||||
scope.unsetDate = function(date){
|
||||
$(el).datepicker('setDates', scope.event.dates.filter(function(el){
|
||||
return el != date;
|
||||
}));
|
||||
};
|
||||
}
|
||||
}
|
||||
})
|
||||
.directive('rallly-error', function(){
|
||||
return {
|
||||
restrict : 'A',
|
||||
scope: {
|
||||
'message': '='
|
||||
},
|
||||
controller : function($scope){
|
||||
console.log($scope.message);
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue