.factory('Journal', function() {
var journal = [
{
"title": "My 1st Entry",
"content": "This is a sample entry."
}
];
return {
all: function() {
return journal;
},
remove: function(entry) {
journal.splice(journal.indexOf(entry), 1);
},
get: function(entryId) {
for (var i = 0; i < journal.length; i++) {
if (journal[i].id === parseInt(entryId)) {
return journal[i];
}
}
return null;
}
};
})
.factory('Journal', function() {
var journal = [
{
"title": "My 1st Entry",
"content": "This is a sample entry."
}
];
return {
all: function() {
return journal;
},
remove: function(entry) {
journal.splice(journal.indexOf(entry), 1);
},
get: function(entryId) {
for (var i = 0; i < journal.length; i++) {
if (journal[i].id === parseInt(entryId)) {
return journal[i];
}
}
return null;
},
add: function(entry) {
journal.push(entry);
}
};
})
$ionicModal
$ionicModal.fromTemplateUrl('templates/modal.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});
$scope.modal.show();
$scope.modal.hide();
Add Entry
$ionicPopup
var alertPopup = $ionicPopup.alert({
title: 'STOP RIGHT THERE!',
template: 'Please fill out all fields.',
buttons: [{ // Array[Object] (optional). Buttons to place in the popup footer.
text: 'Say you\'re sorry.',
type: 'button-royal'
}]
});
.factory('Journal', function() {
// Give us an example object
var journal = [
{
"title": "My 1st Entry",
"content": "This is a sample entry."
}
];
// If we have a journal object, use that!
if (localStorage.journal)
journal = JSON.parse(localStorage.journal);
var save = function() {
localStorage.journal = JSON.stringify(journal);
};
return {
all: function() {
return journal;
},
remove: function(entry) {
journal.splice(journal.indexOf(entry), 1);
save();
},
get: function(entryId) {
for (var i = 0; i < journal.length; i++) {
if (journal[i].id === parseInt(entryId)) {
return journal[i];
}
}
return null;
},
add: function(entry) {
journal.push(entry);
save();
}
};
})
cordova plugin add cordova-plugin-camera
$cordovaCamera
var options = {
quality: 50,
sourceType: Camera.PictureSourceType.CAMERA,
cameraDirection: 0,
destinationType: Camera.DestinationType.DATA_URL,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 500,
targetHeight: 600,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function (imageData) {
var photo = "data:image/jpeg;base64," + imageData;
addPost(null, photo);
}, function (err) {
// error
console.error(err);
takeAFakePicture();
});
cordova plugin add cordova-plugin-geolocation
$cordovaGeolocation
var posOptions = {timeout: 10000, enableHighAccuracy: false};
$cordovaGeolocation
.getCurrentPosition(posOptions)
.then(function (position) {
var lat = position.coords.latitude
var long = position.coords.longitude
}, function(err) {
// error
});