Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // APP.JS
- angular.module('starter', ['angularytics', 'ionic', 'starter.controllers', 'starter.services'])
- .config(function(AngularyticsProvider) {
- AngularyticsProvider.setEventHandlers(['Console', 'GoogleUniversal']);
- })
- .run(function(Angularytics) {
- Angularytics.init();
- })
- .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
- // setup an abstract state for the tabs directive
- .state('tab', {
- url: "/tab",
- abstract: true,
- templateUrl: "templates/tabs.html"
- })
- .state('tab.dash', {
- url: '/dash',
- views: {
- 'tab-dash': {
- templateUrl: 'templates/tab-dash.html',
- controller: 'DashCtrl'
- }
- }
- })
- .state('tab.friends', {
- url: '/friends',
- views: {
- 'tab-friends': {
- templateUrl: 'templates/tab-friends.html',
- controller: 'FriendsCtrl'
- }
- }
- })
- .state('tab.friend-detail', {
- url: '/friend/:friendId',
- views: {
- 'tab-friends': {
- templateUrl: 'templates/friend-detail.html',
- controller: 'FriendDetailCtrl'
- }
- }
- })
- .state('tab.account', {
- url: '/account',
- views: {
- 'tab-account': {
- templateUrl: 'templates/tab-account.html',
- controller: 'AccountCtrl'
- }
- }
- })
- $urlRouterProvider.otherwise('/tab/dash');
- });
- // SERVICES.JS
- angular.module('starter.services', [])
- .factory('Friends', function() {
- var friends = [
- { id: 0, name: 'Scruff McGruff' },
- { id: 1, name: 'G.I. Joe' },
- { id: 2, name: 'Miss Frizzle' },
- { id: 3, name: 'Ash Ketchum' }
- ];
- return {
- all: function() {
- return friends;
- },
- get: function(friendId) {
- return friends[friendId];
- }
- }
- });
- // CONTROLLERS.JS
- angular.module('starter.controllers', [])
- .controller('DashCtrl', function($scope) {
- })
- .controller('FriendsCtrl', function($scope, Friends) {
- $scope.friends = Friends.all();
- })
- .controller('FriendDetailCtrl', function($scope, $stateParams, Friends) {
- $scope.friend = Friends.get($stateParams.friendId);
- })
- .controller('AccountCtrl', function($scope) {
- });
- // INDEX.HTML
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
- <title></title>
- <link href="lib/ionic/css/ionic.css" rel="stylesheet">
- <link href="css/style.css" rel="stylesheet">
- <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
- <link href="css/ionic.app.css" rel="stylesheet">
- -->
- <script src="lib/ionic/js/ionic.bundle.js"></script>
- <script src="cordova.js"></script>
- <script src="js/app.js"></script>
- <script src="js/controllers.js"></script>
- <script src="js/services.js"></script>
- <script src="js/angularytics.min.js"></script>
- <script>
- (function (i, s, o, g, r, a, m) {
- i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
- (i[r].q = i[r].q || []).push(arguments)
- }, i[r].l = 1 * new Date(); a = s.createElement(o),
- m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
- })(window, document, 'script', 'http://www.google-analytics.com/analytics.js', 'ga');
- ga('create', 'UA-48718316-3', 'auto');
- ga('set', 'checkProtocolTask', null);
- </script>
- </head>
- <body ng-app="starter" animation="slide-left-right-ios7">
- <ion-nav-bar class="bar-stable nav-title-slide-ios7">
- <ion-nav-back-button class="button-icon icon ion-ios7-arrow-back">
- Back
- </ion-nav-back-button>
- </ion-nav-bar>
- <ion-nav-view></ion-nav-view>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement