Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49186

How to fix Cannot read property 'calendar' of undefined

$
0
0

@anthonymg94 wrote:

app.controller('programaCtrl', function( $scope, $state, $stateParams, $timeout, $rootScope, $cordovaCalendar) {
var programa = $stateParams.programa;
$scope.programa = programa;

var item = {
		title: programa.titulo,
		location: programa.ubicacion,
		startDate: new Date(programa.fecha_inicio),
		endDate: new Date(programa.fecha_fin)
	};
		console.log(item);
var checkEvent = function(){
	$cordovaCalendar.findEvent(item)
		.then(function (result) {
			console.log('kkjk'+result);
			if (result.length.toString() == '0') {
				$scope.programa.calendario = 'Agregar al calendario +';
			} else {
				$scope.programa.calendario = 'Remover del calendario -';
			}
		},
		function (error) {
			alert('Ocurrio un problema al obtener los datos del calendario, por favor vuelve a intentar: ' + JSON.stringify(error));
});
}
$scope.addEvento = function() {
	if($scope.programa.calendario === 'Agregar al calendario +'){
		$cordovaCalendar.createEvent(item)
			.then(function (result) {
				checkEvent();
			},function (error) {
				alert('Ocurrio un problema al agregar al calendario, por favor vuelve a intentar: ' + JSON.stringify(error));
			});
	}else{
		$cordovaCalendar.deleteEvent(item)
			.then(function (result) {
				checkEvent();
			},
			function (error) {
				alert('Ocurrio un problema al borrar en el calendario, por favor vuelve a intentar: ' + JSON.stringify(error));
			});
	}
}

checkEvent();

})

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>