{"id":16500,"date":"2017-03-08T12:15:02","date_gmt":"2017-03-08T10:15:02","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=16500"},"modified":"2017-03-07T14:41:08","modified_gmt":"2017-03-07T12:41:08","slug":"getting-started-ionic-2","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/","title":{"rendered":"Getting Started With Ionic 2"},"content":{"rendered":"<p>These days, everyone wants to have an \u201cApp\u201d to represent them, their company, or just to perform some common task they might have in mind.<\/p>\n<p>The problem with this is that there is so much to mobile app development. iPhone apps require that you have a Mac to compile them. Android apps have to deal with <a href=\"https:\/\/developer.android.com\/about\/dashboards\/index.html\">platform fragmentation<\/a>. iPhone apps can mean working with Objective C, Android can mean Java\u2013 and if you aren\u2019t a polyglot and fluent in both these languages, you probably feel that mobile app development is quite the daunting task.<\/p>\n<p>Luckily, though, there are other options to choose from. One option that I\u2019ve been working with lately is Ionic, specifically the <a href=\"http:\/\/ionic.io\/2\">Ionic 2 framework<\/a>.<\/p>\n<p>In this blog, we\u2019ll show just how easy it is to get up and running with a Ionic 2 by creating a reference mobile application. By the end of this blog, our application will have the ability to run in the browser, emulator, or be built-out to run on a device.<\/p>\n<h2>About Ionic<\/h2>\n<p>Note: As of this writing, Ionic 2 is in public preview. This means that it is more of a release candidate, and it may not be the full-fledged framework yet. That said, it\u2019s most likely that core framework changes will no longer be happening.<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16502 size-thumbnail\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic1-150x150.png\" width=\"150\" height=\"150\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic1-150x150.png 150w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic1-300x300.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic1-70x70.png 70w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic1.png 452w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/a><\/p>\n<p>Ionic leverages commonly used web technologies to build out the app, specifically <a href=\"https:\/\/angular.io\">Angular<\/a> with <a href=\"https:\/\/www.typescriptlang.org\/\">TypeScript<\/a>, SCSS, and HTML. You\u2019ll want a little knowledge in each of these areas, but if you\u2019re not extremely strong in these areas, don\u2019t worry; the Ionic site offers plenty of examples to help get you through most situations.<\/p>\n<h2>Let\u2019s Get Started<\/h2>\n<p>First we need to have NodeJS installed. If you don\u2019t have this installed, head on over to <a href=\"http:\/\/nodejs.org\/\">NodeJs.org<\/a> to a package that is Node.js 6 or greater. Once installed, open your command prompt or terminal window and type the following to install Ionic and its dependencies:<\/p>\n<pre class=\"brush:java\">npm install -g ionic cordova<\/pre>\n<p>Now that we have Ionic installed, we are ready to start running forward. In your command prompt or terminal window, navigate to the folder where you\u2019d like to save your new application. Type the following:<\/p>\n<pre class=\"brush:java\">ionic start MyFirstApp --v2<\/pre>\n<p>A quick breakdown of this command is to tell Ionic we are <code>start<\/code>ing an application we call <code>MyFirstApp<\/code> and that Ionic should be using version to (\u2013v2). If we were to fail to specify the <code>--v2 flag<\/code>, Ionic would use version 1 of the Ionic framework.<\/p>\n<p>Ionic, from the command above, has now created a project for you to start working with. In fact, at this point, you could even run the project in the browser to start playing.<\/p>\n<p>You\u2019ll need to make sure you\u2019re in the right directory before you can serve up the application. You can do this by typing in <code>CD MyFirstApp<\/code>.<\/p>\n<p>From here, you can type the following to serve up the application:<\/p>\n<pre class=\"brush:java\">ionic serve<\/pre>\n<p>We just told Ionic that we want to serve the application to the browser. In order for it to do this, Ionic will take any TypeScript files and SCSS files, and transpile\/compile them out to something that the browser can digest. Then it starts up a server for us to hit. When it has completed, it will launch the browser for you.<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic1.5.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16503 size-full\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic1.5.png\" width=\"320\" height=\"218\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic1.5.png 320w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic1.5-300x204.png 300w\" sizes=\"(max-width: 320px) 100vw, 320px\" \/><\/a><\/p>\n<p><strong>Boom<\/strong>, you have your first app. But this is just the beginning!<\/p>\n<h3>Custom App<\/h3>\n<p>At this point, we can start moving forward to making a custom app for our needs.<\/p>\n<p>We\u2019ll start by making a simple application for Keyhole Software. This app will give an overview of Keyhole Software, show the location of Keyhole offices, and show a contact page.<\/p>\n<h2>Home Page<\/h2>\n<p>We\u2019ll do a quick update to the <code>home.html<\/code> page:<\/p>\n<pre class=\"brush:xml\">&lt;ion-content padding&gt;\r\n  &lt;img src=\"https:\/\/keyholesoftware.com\/wp-content\/uploads\/2011\/10\/keyholelogo.png\" alt=\"logo\" \/&gt;&lt;br \/&gt;&lt;br \/&gt;\r\n  &lt;p&gt;\r\n    Keyhole Software is a Midwest-based software development and consulting firm with a team that loves technology. Our expert employee consultants excel as \u201cchange agents,\u201d helping our clients to be successful with software technologies that bring competitive advantage. See some of our recent projects &lt;a href=\"https:\/\/keyholesoftware.com\/projects\/\"&gt;here&lt;\/a&gt;.\r\n  &lt;\/p&gt;  \r\n  &lt;p class=\"standout\"&gt;\r\n    &lt;strong&gt;\r\n      &lt;ion-icon ios=\"ios-cog\" md=\"md-cog\"&gt;&lt;\/ion-icon&gt;\r\n      We frequently assist clients with custom application design, development, and modernization initiatives with Java, JavaScript\/SPA, and .NET technologies.\r\n    &lt;\/strong&gt;\r\n  &lt;\/p&gt;  \r\n  &lt;p&gt;\r\n    Keyhole was founded on the principle of delivering quality solutions through a talented technical team, and as such, knowledge transfer is important to us. We have a weekly &lt;a href=\"https:\/\/keyholesoftware.com\/blog\"&gt;development blog&lt;\/a&gt;, as well as in-team Tech Nights to keep up on the latest in the industry. To our clients, we offer various techniques to provide the most value: one-on-one or group mentoring, lab\/lecture educational &lt;a href=\"https:\/\/keyholesoftware.com\/services\/education\/\"&gt;courses&lt;\/a&gt;, and access to our knowledge transfer engine &lt;a href=\"http:\/\/www.grokola.com\/\"&gt;GrokOla&lt;\/a&gt;.\r\n  &lt;\/p&gt;\r\n&lt;\/ion-content&gt;<\/pre>\n<p>\u2014<\/p>\n<pre class=\"brush:java\">page-home {\r\n\t.standout {\r\n\t\tmargin: 3rem 0 3rem 2rem;\r\n\t\tfont-size: 1.5rem;\r\n\t}\r\n}<\/pre>\n<p>Now our application has a home page set up. There\u2019s nothing crazy here to explain, your run-of-the-mill html with an icon.<\/p>\n<p>Ionic provides its own list of icons that we can use. One neat thing about this is that it will use the appropriate icon given the platform you are using, for instance iPhone, Android, etc\u2026<\/p>\n<h2>Contact Page<\/h2>\n<p>Okay, now let\u2019s move on to the next easy page: the contact tab. We will update this page with the following:<\/p>\n<pre class=\"brush:xml\">&lt;ion-header&gt;\r\n  &lt;ion-navbar&gt;\r\n    &lt;ion-title&gt;\r\n      Contact\r\n    &lt;\/ion-title&gt;\r\n  &lt;\/ion-navbar&gt;\r\n&lt;\/ion-header&gt;\r\n\r\n&lt;ion-content padding&gt;\r\n\t&lt;ion-list&gt;\r\n\t\t&lt;ion-item text-wrap&gt;\r\n\t\t\t&lt;h1&gt;Keyhole Software Headquarters&lt;\/h1&gt;\r\n\t\t\t&lt;div&gt;\r\n\t\t\t\t&lt;p&gt;\r\n\t\t\t\t\tThe Keyhole Software corporate office is located in Leawood, Kansas, just south of Kansas City. Additional teams are located in St. Louis, Chicago, Lincoln, and Omaha. We consult nationally with clients across the United States.\r\n\t\t\t\t&lt;\/p&gt;\r\n\t\t\t&lt;\/div&gt;\r\n\t\t\t&lt;br \/&gt;\r\n\t\t\t&lt;div&gt;\r\n\t\t\t\t&lt;p&gt;\r\n\t\t\t\t\t8900 State Line Road, Suite 455&lt;br \/&gt;\r\n\t\t\t\t\tLeawood, KS 66206\r\n\t\t\t\t&lt;\/p&gt;&lt;br \/&gt;\r\n\t\t\t\t&lt;p&gt;\r\n\t\t\t\t\tTel: &lt;a href=\"tel:1-877-521-7769\"&gt;(877) 521-7769&lt;\/a&gt;\r\n\t\t\t\t&lt;\/p&gt;\r\n\t\t\t&lt;\/div&gt;\r\n\t\t&lt;\/ion-item&gt;\r\n\t\t&lt;ion-item text-wrap&gt;\r\n\t\t\t&lt;h1&gt;Connect With Keyhole&lt;\/h1&gt;\r\n\t\t\t&lt;div class=\"x-text cs-ta-left\"&gt;\r\n\t\t\t\t&lt;p&gt;\r\n\t\t\t\t\tWe are prolific in using social media and blogging to connect with the community. Get connected with us on our weekly\u00a0&lt;a href=\"https:\/\/keyholesoftware.com\/blog\/\"&gt;development blog&lt;\/a&gt;, monthly\u00a0&lt;a href=\"https:\/\/keyholesoftware.com\/company\/creations\/publications\/technical-newsletter-sign-up\/\"&gt;developer newsletter&lt;\/a&gt;, or via the social media channels below:\r\n\t\t\t\t&lt;\/p&gt;\t\t\t\t\r\n\t\t\t&lt;\/div&gt;\r\n\t\t\t&lt;br \/&gt;\r\n\t\t\t&lt;div&gt;\r\n\t\t\t\t&lt;p style=\"font-size: 2.5rem; text-align: center;\"&gt;\r\n\t\t\t\t\t&lt;a href=\"http:\/\/twitter.com\/keyholesoftware\" target=\"_blank\"&gt;&lt;ion-icon name=\"logo-twitter\"&gt;&lt;\/ion-icon&gt;&lt;\/a&gt;\r\n\t\t\t\t\t\u00a0\u00a0\u00a0\r\n\t\t\t\t\t&lt;a href=\"http:\/\/linkedin.com\/company\/keyhole-software\" target=\"_blank\"&gt;&lt;ion-icon name=\"logo-linkedin\"&gt;&lt;\/ion-icon&gt;&lt;\/a&gt;\r\n\t\t\t\t\t\u00a0\u00a0\u00a0\r\n\t\t\t\t\t&lt;a href=\"http:\/\/facebook.com\/keyholesoftware\" target=\"_blank\"&gt;&lt;ion-icon name=\"logo-facebook\"&gt;&lt;\/ion-icon&gt;&lt;\/a&gt;\r\n\t\t\t\t\t\u00a0\u00a0\u00a0\r\n\t\t\t\t\t&lt;a href=\"http:\/\/youtube.com\/keyholesoftware\" target=\"_blank\"&gt;&lt;ion-icon name=\"logo-youtube\"&gt;&lt;\/ion-icon&gt;&lt;\/a&gt;\r\n\t\t\t\t\t\u00a0\u00a0\u00a0\r\n\t\t\t\t\t&lt;a href=\"http:\/\/github.com\/in-the-keyhole\" target=\"_blank\"&gt;&lt;ion-icon name=\"logo-github\"&gt;&lt;\/ion-icon&gt;&lt;\/a&gt;\r\n\t\t\t\t\t\u00a0\u00a0\u00a0\r\n\t\t\t\t\t&lt;a href=\"mailto:asktheteam@keyholesoftware.com&amp;subject=Website Inquiry\" target=\"_blank\"&gt;&lt;ion-icon name=\"mail\"&gt;&lt;\/ion-icon&gt;&lt;\/a&gt;\r\n\t\t\t\t\t\u00a0\u00a0\u00a0\r\n\t\t\t\t\t&lt;a href=\"https:\/\/keyholesoftware.com\/feed\" target=\"_blank\"&gt;&lt;ion-icon name=\"logo-rss\"&gt;&lt;\/ion-icon&gt;&lt;\/a&gt;\r\n\t\t\t\t&lt;\/p&gt;\r\n\t\t\t&lt;\/div&gt;\r\n\t\t&lt;\/ion-item&gt;\r\n\t&lt;\/ion-list&gt;\r\n&lt;\/ion-content&gt;<\/pre>\n<p>As you can see with this example, you don\u2019t necessarily have to utilize the SCSS page for styling. You can feel free to style inline or in the SCSS page. This page also makes use of the <code><\/code> and <code><\/code>. This allows us to list out our information in a clean manner. We also make use of the <code>text-wrap<\/code> attribute to let Ionic know that it should wrap the text inside of the <code>ion-item<\/code>. Otherwise the overflow would run off the screen.<\/p>\n<h2>Location Page<\/h2>\n<p>Alright, on to something more complex. For this, we will be adding a new page that will show the locations of the Keyhole offices. We\u2019ll need to generate a new page. Lucky for us, Ionic provides some help for us.<\/p>\n<p>In your command prompt or terminal, make sure you\u2019re at the root of your application in the folder <code>MyFirstApp<\/code>. Type the following command:<\/p>\n<pre class=\"brush:perl\">ionic g page Locations<\/pre>\n<p>With the above command, Ionic will create an HTML, SCSS, and TS file for you.<\/p>\n<p>Now let\u2019s add some content to this page. We will be making use of the Google Maps JavaScript API to show the locations of each of the Keyhole offices. To do so, we will need to update the <code>index.html<\/code> file to add the Google Maps API source. Next, we\u2019ll add a DIV to our <code>locations.html<\/code> page to put the map into. Finally, we\u2019ll add the TypeScript that will create the map and add the markers.<\/p>\n<pre class=\"brush:java\">import { NgModule, ErrorHandler } from '@angular\/core';\r\nimport { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';\r\nimport { MyApp } from '.\/app.component';\r\nimport { ContactPage } from '..\/pages\/contact\/contact';\r\nimport { HomePage } from '..\/pages\/home\/home';\r\nimport { TabsPage } from '..\/pages\/tabs\/tabs';\r\nimport { LocationsPage } from '..\/pages\/locations\/locations';\r\n\r\n@NgModule({\r\n  declarations: [\r\n    MyApp,\r\n    ContactPage,\r\n    HomePage,\r\n\tLocationsPage,\r\n    TabsPage\r\n  ],\r\n  imports: [\r\n    IonicModule.forRoot(MyApp)\r\n  ],\r\n  bootstrap: [IonicApp],\r\n  entryComponents: [\r\n    MyApp,\r\n    ContactPage,\r\n    HomePage,\r\n\tLocationsPage,\r\n    TabsPage\r\n  ],\r\n  providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]\r\n})\r\nexport class AppModule {}<\/pre>\n<p>\u2014<\/p>\n<pre class=\"brush:xml\">&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\" dir=\"ltr\"&gt;\r\n&lt;head&gt;\r\n  &lt;meta charset=\"UTF-8\"&gt;\r\n  &lt;title&gt;Ionic App&lt;\/title&gt;\r\n  &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no\"&gt;\r\n  &lt;meta name=\"format-detection\" content=\"telephone=no\"&gt;\r\n  &lt;meta name=\"msapplication-tap-highlight\" content=\"no\"&gt;\r\n  &lt;link rel=\"icon\" type=\"image\/x-icon\" href=\"assets\/icon\/favicon.ico\"&gt;\r\n  &lt;link rel=\"manifest\" href=\"manifest.json\"&gt;\r\n  &lt;meta name=\"theme-color\" content=\"#4e8ef7\"&gt;\r\n  &lt;script src=\"cordova.js\"&gt;&lt;\/script&gt;\r\n    \r\n  &lt;!-- load google map api --&gt;\r\n  &lt;script src=\"http:\/\/maps.google.com\/maps\/api\/js\"&gt;&lt;\/script&gt;\r\n   \r\n  &lt;link href=\"build\/main.css\" rel=\"stylesheet\"&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n  &lt;!-- Ionic's root component and where the app will load --&gt;\r\n  &lt;ion-app&gt;&lt;\/ion-app&gt;\r\n  &lt;!-- The polyfills js is generated during the build process --&gt;\r\n  &lt;script src=\"build\/polyfills.js\"&gt;&lt;\/script&gt;\r\n  &lt;!-- The bundle js is generated during the build process --&gt;\r\n  &lt;script src=\"build\/main.js\"&gt;&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u2014<\/p>\n<pre class=\"brush:xml\">&lt;ion-header&gt;\r\n  &lt;ion-navbar&gt;\r\n    &lt;ion-title&gt;Office Locations&lt;\/ion-title&gt;\r\n  &lt;\/ion-navbar&gt;\r\n&lt;\/ion-header&gt;\r\n\r\n&lt;ion-content&gt;\r\n\t&lt;div class=\"map\" #map style=\"height: 100%;\"&gt;&lt;\/div&gt;\r\n&lt;\/ion-content&gt;<\/pre>\n<p>\u2014<\/p>\n<pre class=\"brush:java\">import {Component, ViewChild, ElementRef} from \"@angular\/core\";\r\nimport { NavController, NavParams } from 'ionic-angular';\r\n\r\ndeclare var google: any;\r\n\r\n@Component({\r\n  selector: 'page-locations',\r\n  templateUrl: 'locations.html'\r\n})\r\nexport class LocationsPage {\r\n\r\n  public map: any;\r\n\r\n  @ViewChild('map') mapElement: ElementRef;\r\n\r\n  constructor(public navCtrl: NavController, public navParams: NavParams) {}\r\n\r\n  ionViewDidLoad() {\r\n    \tconsole.log('ionViewDidLoad LocationsPage');\r\n\tthis.loadMap();\r\n  }\r\n\r\n  loadMap() { \/\/ TODO: Most of this can probably be moved to the base framework\r\n        console.log(\"loadMap executing\");\r\n        \r\n        let latitude = 40.600920\r\n        let longitude = -91.702881;\r\n\r\n        let latLng = new google.maps.LatLng(latitude, longitude);\r\n\r\n        let mapOptions = {\r\n        \tcenter: latLng,\r\n        \tzoom: 5,\r\n\t \tmaxZoom: 5,\r\n\t\tminZoom: 5,\r\n\t\tpanControl: false,\r\n\t\tdraggable: false,\r\n        \tmapTypeId: google.maps.MapTypeId.ROADMAP,\r\n        \tmapTypeControl: false,\r\n        \tzoomControl: false,\r\n        \tstreetViewControl: false\r\n        };\r\n\r\n        this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);\r\n\r\n        this.setMarkers();\r\n        this.refreshTheMap();\r\n    }\r\n\t\t\r\n    refreshTheMap() { \/\/ TODO: Move this to a map handler class to reuse in our base\r\n        \/\/ refresh map\r\n        setTimeout(() =&gt; {\r\n            google.maps.event.trigger(this.map, 'resize');\r\n        }, 300);\r\n    }\r\n\t\r\n    setMarkers() {\r\n\tconsole.log(\"Setting markers\");\r\n\t    \r\n\tlet lincoln = {lat: 40.832255, lng: -96.674194};\r\n\tlet kansasCity = {lat: 39.046653, lng: -94.586792};\r\n\tlet stLouis = {lat: 38.627331, lng: -90.214233};\r\n\tlet chicago = {lat: 41.879531, lng: -87.621460};\r\n\r\n\tlet lincolnMarker = new google.maps.Marker({\r\n\t\tposition: lincoln,\r\n\t\tmap: this.map,\r\n\t\ttitle: 'Keyhole Lincoln\/Omaha'\r\n\t});\r\n\t\t\r\n\tlet kansasCityMarker = new google.maps.Marker({\r\n\t\tposition: kansasCity,\r\n\t\tmap: this.map,\r\n\t\ttitle: 'Keyhole HQ'\r\n\t});\r\n\r\n\tlet stLouisMarker = new google.maps.Marker({\r\n\t\tposition: stLouis,\r\n\t\tmap: this.map,\r\n\t\ttitle: 'Keyhole St Louis'\r\n\t});\r\n\t\t\r\n\tlet chicagoMarker = new google.maps.Marker({\r\n\t\tposition: chicago,\r\n\t\tmap: this.map,\r\n\t\ttitle: 'Keyhole Chicago'\r\n\t});\r\n\r\n\tlincolnMarker.setMap(this.map);\r\n\tkansasCityMarker.setMap(this.map);\r\n\tstLouisMarker.setMap(this.map);\r\n\tchicagoMarker.setMap(this.map);\r\n\r\n\tconsole.log(\"Markers set\")\r\n   }  \r\n}<\/pre>\n<p>The application won\u2019t inherently know about our new Locations page so we need to fix this by updating a few things in the <code>app.module.ts<\/code> file. At the top of the page, we add a new <code>import<\/code> for the <code>LocationsPage<\/code> that points to the path of the HTML file. Now that we have imported the page into <code>app.module.ts<\/code>, we need to insert it into the <code>declarations<\/code> and <code>entryComponents<\/code> arrays. Once we have done this, Ionic will understand what to include for compilation of the app so that we can start using it.<\/p>\n<p>We now have our location page set up and ready to go. However, we need to also add the page to our tabs system so that we can quickly navigate to the page. To do so we need to update the files below:<\/p>\n<pre class=\"brush:xml\">&lt;ion-tabs&gt;\r\n  &lt;ion-tab [root]=\"tab1Root\" tabTitle=\"Home\" tabIcon=\"home\"&gt;&lt;\/ion-tab&gt;\r\n  &lt;ion-tab [root]=\"tab2Root\" tabTitle=\"Locations\" tabIcon=\"pin\"&gt;&lt;\/ion-tab&gt;\r\n  &lt;ion-tab [root]=\"tab3Root\" tabTitle=\"Contact\" tabIcon=\"contacts\"&gt;&lt;\/ion-tab&gt;\r\n&lt;\/ion-tabs&gt;<\/pre>\n<p>\u2014<\/p>\n<pre class=\"brush:java\">import { Component } from '@angular\/core';\r\nimport { HomePage } from '..\/home\/home';\r\nimport { LocationsPage } from '..\/locations\/locations';\r\nimport { ContactPage } from '..\/contact\/contact';\r\n\r\n@Component({\r\n  templateUrl: 'tabs.html'\r\n})\r\nexport class TabsPage {\r\n  \/\/ this tells the tabs component which Pages\r\n  \/\/ should be each tab's root Page\r\n  tab1Root: any = HomePage;\r\n  tab2Root: any = LocationsPage;\r\n  tab3Root: any = ContactPage;\r\n\r\n  constructor() { }\r\n}<\/pre>\n<h2>Testing<\/h2>\n<p>Now we have our application set up, we are ready to test it out.<\/p>\n<p>Run the <code>ionic serve<\/code> command again to test out our app. You should now see something similar to the below image. (Note: you can resize your browser to achieve the phone-sized page.)<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic2.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-16504\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic2.png\" alt=\"\" width=\"400\" height=\"232\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic2.png 400w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/GettingStartedwithIonic2-300x174.png 300w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<h2>Final Thoughts<\/h2>\n<p>In this blog, we created a mobile application using the Ionic 2 framework that can be run in the browser, emulator, or built-out to run on a device. I hope that you found it helpful in getting to know the Ionic 2 framework a bit better. Thank you for following along!<\/p>\n<p>To see the working application source, visit this link: <a href=\"https:\/\/github.com\/costr\/Keyhole-Ionic-Starter\">https:\/\/github.com\/costr\/Keyhole-Ionic-Starter<\/a>.<\/p>\n<h2>References<\/h2>\n<p><a href=\"http:\/\/ionic.io\/2\">http:\/\/ionic.io\/2<\/a><br \/>\n<a href=\"https:\/\/www.typescriptlang.org\/\">https:\/\/www.typescriptlang.org\/<\/a><br \/>\n<a href=\"https:\/\/angular.io\">https:\/\/angular.io<\/a><\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"https:\/\/keyholesoftware.com\/2017\/03\/06\/getting-started-with-ionic-2\/\">Getting Started With Ionic 2<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a>\u00a0Adam Costenbader at the <a href=\"http:\/\/keyholesoftware.com\/\">Keyhole Software<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>These days, everyone wants to have an \u201cApp\u201d to represent them, their company, or just to perform some common task they might have in mind. The problem with this is that there is so much to mobile app development. iPhone apps require that you have a Mac to compile them. Android apps have to deal &hellip;<\/p>\n","protected":false},"author":222,"featured_media":909,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[187],"class_list":["post-16500","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-angular-js","tag-ionic"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Getting Started With Ionic 2 - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"These days, everyone wants to have an \u201cApp\u201d to represent them, their company, or just to perform some common task they might have in mind. The problem\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Getting Started With Ionic 2 - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"These days, everyone wants to have an \u201cApp\u201d to represent them, their company, or just to perform some common task they might have in mind. The problem\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-03-08T10:15:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Adam Costenbader\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Adam Costenbader\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/\"},\"author\":{\"name\":\"Adam Costenbader\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/70c7ae089b7e5163b402f2d03660b88d\"},\"headline\":\"Getting Started With Ionic 2\",\"datePublished\":\"2017-03-08T10:15:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/\"},\"wordCount\":1195,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"keywords\":[\"Ionic\"],\"articleSection\":[\"Angular.js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/\",\"name\":\"Getting Started With Ionic 2 - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"datePublished\":\"2017-03-08T10:15:02+00:00\",\"description\":\"These days, everyone wants to have an \u201cApp\u201d to represent them, their company, or just to perform some common task they might have in mind. The problem\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Angular.js\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/angular-js\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Getting Started With Ionic 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/70c7ae089b7e5163b402f2d03660b88d\",\"name\":\"Adam Costenbader\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ff4b9ce1b070c8e83a03d062a8cf7dbeee0169b112548cb2a65b94ec69173ac8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ff4b9ce1b070c8e83a03d062a8cf7dbeee0169b112548cb2a65b94ec69173ac8?s=96&d=mm&r=g\",\"caption\":\"Adam Costenbader\"},\"description\":\"Adam is a Consultant at Keyhole focusing on .NET and web application technologies. He strives to help foster a team that feels strong in their communication and technical expertise by listening and teaching.\",\"url\":\"https:\/\/www.webcodegeeks.com\/author\/adam-costenbader\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Getting Started With Ionic 2 - Web Code Geeks - 2026","description":"These days, everyone wants to have an \u201cApp\u201d to represent them, their company, or just to perform some common task they might have in mind. The problem","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/","og_locale":"en_US","og_type":"article","og_title":"Getting Started With Ionic 2 - Web Code Geeks - 2026","og_description":"These days, everyone wants to have an \u201cApp\u201d to represent them, their company, or just to perform some common task they might have in mind. The problem","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-03-08T10:15:02+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","type":"image\/jpeg"}],"author":"Adam Costenbader","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Adam Costenbader","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/"},"author":{"name":"Adam Costenbader","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/70c7ae089b7e5163b402f2d03660b88d"},"headline":"Getting Started With Ionic 2","datePublished":"2017-03-08T10:15:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/"},"wordCount":1195,"commentCount":1,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","keywords":["Ionic"],"articleSection":["Angular.js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/","name":"Getting Started With Ionic 2 - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","datePublished":"2017-03-08T10:15:02+00:00","description":"These days, everyone wants to have an \u201cApp\u201d to represent them, their company, or just to perform some common task they might have in mind. The problem","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/angularjs-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/angular-js\/getting-started-ionic-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Angular.js","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/angular-js\/"},{"@type":"ListItem","position":4,"name":"Getting Started With Ionic 2"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/70c7ae089b7e5163b402f2d03660b88d","name":"Adam Costenbader","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ff4b9ce1b070c8e83a03d062a8cf7dbeee0169b112548cb2a65b94ec69173ac8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ff4b9ce1b070c8e83a03d062a8cf7dbeee0169b112548cb2a65b94ec69173ac8?s=96&d=mm&r=g","caption":"Adam Costenbader"},"description":"Adam is a Consultant at Keyhole focusing on .NET and web application technologies. He strives to help foster a team that feels strong in their communication and technical expertise by listening and teaching.","url":"https:\/\/www.webcodegeeks.com\/author\/adam-costenbader\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/16500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/222"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=16500"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/16500\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/909"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=16500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=16500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=16500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}