@jasonhoo95 wrote:
`var imageApp = angular.module('starter', ['ionic','ngCordova','firebase']);
var fb = new Firebase("https://boiling-fire-9767.firebaseio.com/");imageApp.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);// Don't remove this line unless you know what you are doing. It stops the viewport // from snapping when text inputs are focused. Ionic handles this internally for // a much nicer keyboard experience. cordova.plugins.Keyboard.disableScroll(true); } if(window.StatusBar) { StatusBar.styleDefault(); }
});
})imageApp.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state("firebase", {
url: "/firebase",
templateUrl: "firebase.html",
controller: "FirebaseController",
cache: false
})
.state("secure", {
url: "/secure",
templateUrl: "secure.html",
controller: "SecureController"
});
$urlRouterProvider.otherwise('/firebase');
});imageApp.controller("FirebaseController", function($scope, $state, $firebaseAuth) {
var fbAuth = $firebaseAuth(fb); $scope.login = function(username, password) { fbAuth.$authWithPassword({ email: username, password: password }).then(function(authData) { $state.go("secure"); }).catch(function(error) { console.error("ERROR: " + error); }); } $scope.register = function(username, password) { fbAuth.$createUser({email: username, password: password}).then(function(userData) { return fbAuth.$authWithPassword({ email: username, password: password }); }).then(function(authData) { $state.go("secure"); }).catch(function(error) { console.error("ERROR: " + error); }); }
});
imageApp.controller("SecureController", function($scope, $ionicHistory, $firebaseArray, $cordovaCamera) {$ionicHistory.clearHistory(); $scope.images = []; var fbAuth = fb.getAuth(); if(fbAuth) { var userReference = fb.child("users/" + fbAuth.uid); var syncArray = $firebaseArray(userReference.child("images")); $scope.images = syncArray; } else { $state.go("firebase"); } $scope.upload = function() { var options = { quality : 100, destinationType : navigator.camera.DestinationType.DATA_URL, sourceType : navigator.camera.PictureSourceType.PHOTOLIBRARY, allowEdit: true, encodingType: Camera.EncodingType.JPEG, popoverOptions: CameraPopoverOptions, targetWidth: 500, targetHeight: 500, saveToPhotoAlbum: false }; $cordovaCamera.getPicture(options).then(function(imageData) { syncArray.$add({image: imageData}).then(function() { alert("Image has been uploaded"); }); }, function(error) { console.error(error); }); }
});
This is my code for app.js can anyone of you help me out I have no idea what is wrong
Posts: 1
Participants: 1