Labels

Learn the powerful enterprise adaptable database:

Getting Started With ADABAS & Natural

Tuesday, January 10, 2017

200 Ionic Side Menu Apps From Scratch


.
200 Ionic Side Menu Record Book Apps From Scratch
Building On Codepen Platform

1) Setting Up HTML and JS codes

HTML
<html>
 <head>
   <meta charset="utf-8">
   <title>Diary</title>
   <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
   <!-- Internal Library
   <link href="lib/ionic/css/ionic.css" rel="stylesheet">
   <script src="lib/ionic/js/ionic.bundle.js"></script>
   -->
   <!-- Cloud Library -->
   <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
   <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>

   <!-- Needed for Cordova/PhoneGap (will be a 404 during development) -->
   <script src="cordova.js"></script>
 </head>
   <body ng-app="app">
 <div>
 <div>
   <ion-nav-bar class="bar-stable">
     <ion-nav-back-button></ion-nav-back-button>
   </ion-nav-bar>
   <ion-nav-view></ion-nav-view>
 </div>
</div>

   
    <script id="home.html" type="text/ng-template">
<ion-view title="Home" id="page1">
 <ion-content padding="true" class="has-header"></ion-content>
</ion-view>
   </script>    

    <script id="cart.html" type="text/ng-template">
<ion-view title="Cart" id="page2">
 <ion-content padding="true" class="has-header"></ion-content>
</ion-view>
   </script>  

     <script id="cart.html" type="text/ng-template">
<ion-view title="Cart" id="page2">
 <ion-content padding="true" class="has-header"></ion-content>
</ion-view>
   </script>      
      <script id="cloud.html" type="text/ng-template">
<ion-view title="Cloud" id="page3">
 <ion-content padding="true" class="has-header"></ion-content>
</ion-view>
   </script>
     
   <script id="menu.html" type="text/ng-template">
<ion-side-menus enable-menu-with-back-views="false">
 <ion-side-menu-content>
   <ion-nav-bar class="bar-stable">
     <ion-nav-back-button></ion-nav-back-button>
     <ion-nav-buttons side="left">
       <button class="button button-icon button-clear ion-navicon" menu-toggle="left"></button>
     </ion-nav-buttons>
   </ion-nav-bar>
   <ion-nav-view name="side-menu21"></ion-nav-view>
 </ion-side-menu-content>
 <ion-side-menu side="left" id="side-menu21">
   <ion-header-bar class="bar-stable">
     <div class="title">Menu</div>
   </ion-header-bar>
   <ion-content padding="false" class="side-menu-left has-header ">
     <ion-list id="menu-list1">
       <ion-item id="menu-list-item1" ui-sref="menu.home" menu-close="">Home</ion-item>
       <ion-item id="menu-list-item2" ui-sref="menu.cart" menu-close="">Cart</ion-item>
       <ion-item id="menu-list-item3" ui-sref="menu.cloud" menu-close="">Cloud</ion-item>
     </ion-list>
   </ion-content>
 </ion-side-menu>
</ion-side-menus>

   </script>
     
 </body>
</html>
JS
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'app' 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'

angular.module('app', ['ionic'])
.controller('homeCtrl', ['$scope', '$stateParams',
// The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller
// You can include any angular dependencies as parameters for this function
// TIP: Access Route Parameters for your page via $stateParams.parameterName

function ($scope, $stateParams) {


}])
 
.controller('cartCtrl', ['$scope', '$stateParams',
// The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller
// You can include any angular dependencies as parameters for this function
// TIP: Access Route Parameters for your page via $stateParams.parameterName

function ($scope, $stateParams) {


}])
 
.controller('cloudCtrl', ['$scope', '$stateParams',
// The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller
// You can include any angular dependencies as parameters for this function
// TIP: Access Route Parameters for your page via $stateParams.parameterName

function ($scope, $stateParams) {


}])
 
.controller('menuCtrl', ['$scope', '$stateParams',
// The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller
// You can include any angular dependencies as parameters for this function
// TIP: Access Route Parameters for your page via $stateParams.parameterName

function ($scope, $stateParams) {


}])

.config(function($stateProvider, $urlRouterProvider) {

  // Ionic uses AngularUI Router which uses the concept of states
 // Learn more here: https://github.com/angular-ui/ui-router
 // Set up the various states which the app can be in.
 // Each state's controller can be found in controllers.js

 $stateProvider
 


     .state('menu.home', {
   url: '/page1',
   views: {
     'side-menu21': {
       templateUrl: 'home.html',
       controller: 'homeCtrl'
     }
   }
 })

 .state('menu.cart', {
   url: '/page2',
   views: {
     'side-menu21': {
       templateUrl: 'cart.html',
       controller: 'cartCtrl'
     }
   }
 })

 .state('menu.cloud', {
   url: '/page3',
   views: {
     'side-menu21': {
       templateUrl: 'cloud.html',
       controller: 'cloudCtrl'
     }
   }
 })

 .state('menu', {
   url: '/side-menu21',
   templateUrl: 'menu.html',
   controller: 'menuCtrl'
 })

$urlRouterProvider.otherwise('/side-menu21/page1')



});

2) View

3) Download

.

No comments:

Post a Comment