I am attempting to build my first app in ionic. I have the general idea about the structure of the framework. I am just having issues with my javascript. I have added javascript to the app.js file in my ionic 1 app but it is not working. I have tried endless variations and placement of the javascript without it working. Can someone please help me out?
angular.module(‘app’, [‘ionic’, ‘app.controllers’, ‘app.routes’, ‘app.directives’, ‘app.services’ ,])
.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 && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})
$(’#sites input:radio’).addClass(‘input_hidden’);
$(’#sites label’).click(function() {
$(this).addClass(‘selected’).siblings().removeClass(‘selected’);
});
//CALCULATOR START
$(document).ready(function() {
$(’.options’).on(‘change’, ‘input’, function() {
var $self = $(this);
var inputType = $self.attr(‘type’);
if (inputType == 'radio') {
$self.parent('li').addClass('active').siblings().removeClass('active');
} else if (inputType == 'checkbox') {
$self.parent('li').toggleClass('active');
}
runUpdate();
});
});
function runUpdate() {
// get the sum of the elements
var calories = $(".caloriesSum", ‘.active’).sum();
var fat = $(".fatSum", ‘.active’).sum();
var satfat = $(".satfatSum", ‘.active’).sum();
var carbs = $(".carbsSum", ‘.active’).sum();
var protein = $(".proteinSum", ‘.active’).sum();
var sodium = $(".sodiumSum", ‘.active’).sum();
var chloresterol = $(".chloesterolSum", ‘.active’).sum();
// update the total
$("#totalCalories").text(+calories.toString());
$("#totalFat").text(+fat.toString());
$("#totalSatFat").text(+satfat.toString());
$("#totalCarbs").text(+carbs.toString());
$("#totalProtein").text(+protein.toString());
$("#totalSodium").text(+sodium.toString());
$("#totalChloresterol").text(+chloresterol.toString());
}
//CALCULATOR FINISH