Last active
August 29, 2015 14:05
-
-
Save dcbartlett/03028203b7e87a71eec9 to your computer and use it in GitHub Desktop.
Ionic (angular) - Damnit Why not worky?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// angular.module is a global place for creating, registering and retrieving Angular modules | |
// 'Captix' is the name of this angular module example (also set in a <body> attribute in index.html) | |
// the 2nd parameter is an array of 'requires' | |
// 'Captix.controllers' is found in controllers.js | |
angular.module('captix', ['ionic', 'captix.controllers', 'captix.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.Keyboard) { | |
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); | |
} | |
if(window.StatusBar) { | |
// org.apache.cordova.statusbar required | |
StatusBar.styleDefault(); | |
} | |
}); | |
}) | |
.config(function($stateProvider, $urlRouterProvider) { | |
$stateProvider | |
.state('app', { | |
url: "/app", | |
abstract: true, | |
templateUrl: "templates/menu.html", | |
controller: 'AppCtrl' | |
}) | |
.state('app.home', { | |
url: "/home", | |
views: { | |
'menuContent' :{ | |
templateUrl: "templates/home.html" | |
} | |
} | |
}) | |
.state('app.settings', { | |
url: "/settings", | |
views: { | |
'menuContent' :{ | |
templateUrl: "templates/settings.html" | |
} | |
} | |
}) | |
.state('app.info', { | |
url: "/info", | |
views: { | |
'menuContent' :{ | |
templateUrl: "templates/info.html" | |
} | |
} | |
}); | |
// if none of the above states are matched, use this as the fallback | |
$urlRouterProvider.otherwise('/app/home'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('captix.controllers', []) | |
.controller('SettingsCtrl', ['SettingsService', | |
function($scope, $stateParams, SettingsService) { | |
var EventName = SettingsService.getEventName(); | |
SettingsService.setEventName('test'); | |
} | |
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('captix.services', []) | |
.factory('SettingsService', ['DatabaseService', function (DatabaseService) { | |
var Settings = {}; | |
var settings = { | |
event: {} | |
}; | |
Settings.getEventName = function () { | |
return settings.event.name; | |
}; | |
Settings.setEventName = function (value) { | |
settings.event.name = value; | |
return value; | |
}; | |
return Settings; | |
}]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ng-controller="SettingsCtrl"> | |
EventName: | |
{{ EventName }} | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment