Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

App not working when new controllers are added

$
0
0

app js code without the two controllers I want to add

var FBURL = "https://anaphylaxis999.firebaseio.com/";

angular.module('starter', ['ionic', 'firebase','ngCordova','starter.controllers-user','starter.services-auth','starter.services-profile',
'starter.services-codes',
'starter.services-utils',
'starter.services-cordova-camera',])

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);

}
if (window.StatusBar) {
  // org.apache.cordova.statusbar required
  StatusBar.styleDefault();
}
// hide the splash screen only after everything's ready (avoid flicker)
// requires keyboard plugin and confix.xml entry telling the splash screen to stay until explicitly told
if(navigator.splashscreen){
  navigator.splashscreen.hide();
}

});
})

.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: '/app',
abstract: true,
templateUrl: 'templates/menu.html',
controller: 'UserCtrl'
})

.state('app.dash', {
  url: '/dash',
  views: {
    'menuContent': {
      templateUrl: 'templates/dash.html'
    }
  }
})

 .state('app.create_recipe', {
  url: '/create_recipe',
  views: {
    'menuContent': {
      templateUrl: 'templates/create_recipe.html'
    }
  }
})

.state('app.anaphylaxis', {
  url: '/anaphylaxis',
  views: {
    'menuContent': {
      templateUrl: 'templates/Anaphylaxis.html',
    }
  }
});

// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app/dash');
});

then i have a controller.js - this will not work whenever i add the 'myController' to the app.js

angular.module('myControllers', [])

//Feed Controller
.controller('FeedCtrl', ["$scope", "$firebase", "fireRoutes", function($scope, $firebase, fireRoutes){
$scope.posts = $firebase(fireRoutes.refPosts());
}])

//Post Controller
.controller('PostCtrl', ["$scope", "$firebase", "fireRoutes", "$location", function($scope, $firebase, fireRoutes, $location){
$scope.addPost = function() {
var post = {
title: $scope.post.title
};
$firebase(fireRoutes.refPosts()).$add(post);
$location.path("/feed");
};
}]);

services.js - this also doesnt work whenever i add the line of code to the app.js

angular.module('myServices', [])

.factory('fireRoutes', function($firebase) {
var ref = new Firebase("https://ionic-tutorial-ga.firebaseio.com/"),
refPosts = new Firebase("https://ionic-tutorial-ga.firebaseio.com/posts");
return {
ref: function() {
return ref;
},
refPosts: function() {
return refPosts;
}
}
});

if you could help me that would be great

thank you


Viewing all articles
Browse latest Browse all 228595

Trending Articles



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