app.controller('CreateFormController',
['$scope', '$location','Category', 'Post',
function($scope, $location, Category, Post) {
Category.query(function(cat) {
$scope.data = cat;
}, function(errResponse) {
// $location.path('/')
});
$scope.today = function() {
$scope.date = '');
};
$scope.today();
$scope.clear = function() {
$scope.date = null;
};
$scope.disabled = function(date, mode) {
return (mode === 'day' && (date.getDay() === 0 || date.getDay() === 6));
};
$scope.toggleMin = function() {
$scope.midDate = $scope.minDate ? null : new Date();
};
$scope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.opened = true;
};
$scope.dateOptions = {
formatYear: 'yyyy',
startingDay: 1
};
$scope.formats = ['yyyy-MM-dd'];
$scope.format = $scope.formats[0];
$scope.submit = function() {
var res = Post.save({add:$scope.add},function() {
$location.path('/')
}, function(errResponse) {
console.log(errResponse)
});
};
}]);