Introduction

In a previous article, we started with the Ionic framework and discussed the Visual Studio Code where we are going to implement our applications. Now we are going to implement a small application where we will make some menus in the form of the grid using ionic.
Step 1: Open Visual Studio Code,
Code
Step 2: Now after starting Visual studio Code, open a folder where you want to put your application,
application
Step 3: Create a new folder and name it Ionic_Grid_Menu,
Ionic_Grid_Menu
And select that folder,
folder
After we created the folder we can see an Explorer opened with two tabs,
  1. Working Files: shows the present files are in work.
  2. IONIC_GRID_MENU: shows all the files in the folder.
Step 4: Create the files,
Create
  1. index.html
  2. ionic.min.css
  3. style.css
  4. ionic.bundle.min.js
  5. script.min.js
file
Step 5: Let’s code for the application,
index.html:
  1. <html ng-app="ionicApp">
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  5. <title> Menu Buttons</title>
  6. <link href="Style\ionic.min.css" rel="stylesheet">
  7. <link href="Style\style.css" rel="stylesheet">
  8. <script src="JS\ionic.bundle.min.js"></script>
  9. <script src="JS\Script.bundle.js"></script>
  10. </head>
  11. <body ng-controller="MyCtrl">
  12. <ion-header-bar class="bar-positive">
  13. <div class="buttons">
  14. <h1 class="title">Menu buttons</h1>
  15. </div>
  16. </ion-header-bar>
  17. <ion-content id="fhm_page">
  18. <div class="fhm_container">
  19. <div class="fhm_row">
  20. <div class="fhm_item fhm_item1">
  21. <span>Article</span>
  22. </div>
  23. <div class="fhm_item fhm_item2">
  24. <span> Blog</span>
  25. </div>
  26. </div>
  27. <div class="fhm_row">
  28. <div class="fhm_item fhm_item3">
  29. <span> News</span>
  30. </div>
  31. <div class="fhm_item fhm_item4">
  32. <span>Video</span>
  33. </div>
  34. </div>
  35. <div class="fhm_row">
  36. <div class="fhm_item fhm_item5">
  37. <span>Job</span>
  38. </div>
  39. <div class="fhm_item fhm_item6">
  40. <span>Book</span>
  41. </div>
  42. </div>
  43. </div>
  44. </ion-content>
  45. </body>
  46. </html>
style.css
  1. body {
  2. cursor: url('http://ionicframework.com/img/finger.png'),
  3. auto;
  4. }
  5. #fhm_page.scroll,
  6. .fhm_container
  7. {
  8. position: absolute;
  9. top: 0;
  10. right: 0;
  11. left: 0;
  12. bottom: 0;
  13. }
  14. .fhm_row
  15. {
  16. /* position: absolute; */
  17. height: 33.3 % ;
  18. left: 0;
  19. right: 0;
  20. background - color: #FF0000;
  21. clear: both;
  22. }
  23. .fhm_item
  24. {
  25. height: 100 % ;
  26. width: 49.95 % ;
  27. font - family: Arial,
  28. Helvetica,
  29. sans - serif;
  30. font - size: 50 px;
  31. color: white;
  32. text - align: center;
  33. border: 1 px solid# FFFFFF;
  34. float: left;
  35. position: relative;
  36. }
  37. .fhm_item1
  38. {
  39. background - color: #1d8a77;
  40. }
  41. .fhm_item2
  42. {
  43. background-color: # ff6600;
  44. }
  45. .fhm_item3
  46. {
  47. background - color: #dd5151;
  48. }
  49. .fhm_item4
  50. {
  51. background - color: #6bc042;
  52. }
  53. .fhm_item5
  54. {
  55. background-color: # ffca2a;
  56. }
  57. .fhm_item6
  58. {
  59. background - color: #0086dc;
  60. }
  61. span{
  62. position: absolute;
  63. top:0;
  64. right:0;
  65. left:0;
  66. bottom:0;
  67. margin: auto;
  68. width:100%;
  69. height: 10%;
  70. }
ionic.min.css
Download the file from the url
script.bundle.js
  1. angular.module('ionicApp', ['ionic'])
  2. .controller('MyCtrl', function($scope)
  3. {
  4. });
  5. ionic.bundle.min.js
Download the file from the url.
Now we have completed code for our application now run it. Here are the steps,
  1. Press Ctrl+Shift+P.
  2. >ext install chrome (Debugger for Chrome)
    Note:
    Don’t write ext install chrome at once it will not give any output, so first write ext install & press enter and wait for its output and after u will get a list, then write chrome preceding to ext install.
  3. After complete installation, press Ctrl+Shift+D (Debug).
  4. Press F5 or click on the Run symbol.
  5. After pressing, we will ask to select the environment for debug by VS Code, select chrome in that list.
  6. You will get a new file created by default and named launch.json.
  7. Press F5 or click on the Run symbol, Again.
The output of our application will be,
output
Check this for different platforms,
For iPhone 6,
 IPhone 6
For IPad,
IPad
We can use that on any platform and it will work similarly for each platform,
platform
Read more articles on the Ionic framework: