<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Beer Tutorials</title>
    <description>Beer Tutorials</description>
    <link>http://www.beer-tutorials.orghttp://www.beer-tutorials.org/</link>
    <atom:link href="http://www.beer-tutorials.orghttp://www.beer-tutorials.org/feed.xml" rel="self" type="application/rss+xml" />
    <pubDate>Sat, 21 Jan 2017 13:42:25 +0000</pubDate>
    <lastBuildDate>Sat, 21 Jan 2017 13:42:25 +0000</lastBuildDate>
    <generator>Jekyll v3.3.1</generator>
    
      <item>
        <title>Ionic 2 Beers</title>
        <description>&lt;h1 id=&quot;ionic-2-beers&quot;&gt;Ionic 2 Beers&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Ionic Beers&lt;/strong&gt; is a tutorial of the &lt;a href=&quot;http://www.beer-tutorials.org&quot;&gt;Beer Tutorials&lt;/a&gt; series.
In this tutorial we will create a simple app that queries a beer catalog and displays a list of beers.&lt;/p&gt;

&lt;h2 id=&quot;getting-started&quot;&gt;Getting Started&lt;/h2&gt;

&lt;p&gt;Install &lt;a href=&quot;https://nodejs.org/&quot;&gt;NodeJS&lt;/a&gt; and then using the node package manager (npm), install ionic and cordova.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm install -g ionic cordova
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After installing ionic, create a new project called &lt;code class=&quot;highlighter-rouge&quot;&gt;ionic2-beers&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ionic start ionic2-beers blank --v2
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Navigate to the project directory and add the mobile development platform.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ionic platform add android
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Run the application on the Android emulator.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ionic emulate android
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Run the application on desktop browser
&lt;code class=&quot;highlighter-rouge&quot;&gt;
ionic serve --lab
&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Note: To run the application in the Android emulator, you need to have the Android SDK
installed and configured on your computer.
The easiest way to do it is to install &lt;a href=&quot;http://developer.android.com/tools/studio/index.html&quot;&gt;Android Studio&lt;/a&gt;
for your platform.&lt;/p&gt;

  &lt;p&gt;If you have issues while initializing the app, read carefully &lt;a href=&quot;http://ionicframework.com/docs/getting-help/&quot;&gt;these instructions&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;project-structure&quot;&gt;Project Structure&lt;/h2&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;.
└── ionic2-beers
    ├── hooks
    │   ├── after_prepare
    │   │   └── ...
    │   └── README.md
    ├── node_modules
    │   ├── ...
    │   └── ...
    ├── platforms
    │   ├── android
    │   │   └── ...
    │   ├── ios
    │   │   └── ...
    │   └── platform.json
    ├── plugins
    │   ├── ...
    │   ├── fetch.json
    │   └── ios.json
    ├── resources
    │   ├── android
    │   │   └── ...
    │   ├── ios
    │   │   └── ...
    │   ├── icon.png
    │   └── splash.png
    ├── src
    │   ├── app
    │   |     ├── app.component.ts
    │   |     ├── app.html
    │   |     ├── app.module.ts
    │   |     ├── app.scss
    │   |     └── main.ts
    │   ├── assets
    │   |     └── icon
    │   |           └── favicon.ico
    │   ├── pages
    │   |     └── home
    │   |           ├── home.html
    │   |           ├── home.scss
    │   |           └── home.ts
    │   ├── theme
    │   |     └── variables.scss
    │   ├── declaration.d.ts
    │   ├── index.html
    │   ├── manifest.json
    │   └── service-worker.js
    ├── typings
    │   └── cordova-typings.d.ts
    ├── www
    │   ├── index.html
    |   ├── manifest.json
    |   └── service-worker.js
    ├── package.json
    ├── config.xml
    ├── ionic.config.json
    ├── tsconfig.json
    └── tslint.json
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Inside  the project folder there are 8 sub-folders: &lt;code class=&quot;highlighter-rouge&quot;&gt;hooks&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;node_modules&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;platforms&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;plugins&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;resources&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;src&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;typings&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;www&lt;/code&gt;. The application source code resides in the &lt;code class=&quot;highlighter-rouge&quot;&gt;app&lt;/code&gt; folder. Application code is written using Angular2 and Typescript.&lt;/p&gt;

&lt;p&gt;Inside the &lt;code class=&quot;highlighter-rouge&quot;&gt;src&lt;/code&gt; folder is a file called &lt;code class=&quot;highlighter-rouge&quot;&gt;index.html&lt;/code&gt; which has the default application code. Finally &lt;code class=&quot;highlighter-rouge&quot;&gt;app/main.ts&lt;/code&gt; contains the code to start the application with the defined modules.&lt;/p&gt;

&lt;h2 id=&quot;designing-the-app&quot;&gt;Designing the app&lt;/h2&gt;

&lt;h3 id=&quot;beers-list&quot;&gt;Beers list&lt;/h3&gt;

&lt;p&gt;We need to create a new page to list the beers in the application. For that, we’re going to use Ionic CLI to generate pages with command&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ionic generate page beers
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;pages/beers/beers.html&lt;/code&gt; and add the code which define the beers list to display.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ion-content padding&amp;gt;
    &amp;lt;ul&amp;gt;
        &amp;lt;li&amp;gt;
            &amp;lt;span&amp;gt;Affligem Blond&amp;lt;/span&amp;gt;
            &amp;lt;p&amp;gt;
                Affligem Blonde, the classic clear blonde abbey ale, 
                with a gentle roundness and 6.8% alcohol. Low on bitterness, 
                it is eminently drinkable.
            &amp;lt;/p&amp;gt;
        &amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;
            &amp;lt;span&amp;gt;Affligem Tripel&amp;lt;/span&amp;gt;
            &amp;lt;p&amp;gt;
                The king of the abbey beers. It is amber-gold and pours with a 
                deep head and original aroma, 
                delivering a complex, full bodied flavour. Pure enjoyment! Secondary 
                fermentation in the bottle.
            &amp;lt;/p&amp;gt;
        &amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;

    &amp;lt;p&amp;gt;Total number of beers: 2&amp;lt;/p&amp;gt;
&amp;lt;/ion-content&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now, we need to add this new page to the application. Open &lt;code class=&quot;highlighter-rouge&quot;&gt;app/app.component.ts&lt;/code&gt; and add after the import of the HomePage&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import { BeersPage } from '../pages/beers/beers';
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;app/app.module.ts&lt;/code&gt; and add after the import of the HomePage&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import { BeersPage } from '../pages/beers/beers';
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Add the BeersPage in &lt;code class=&quot;highlighter-rouge&quot;&gt;declarations&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;entryComponents&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Save changes.&lt;/p&gt;

&lt;h3 id=&quot;menu&quot;&gt;Menu&lt;/h3&gt;

&lt;p&gt;First, we’re going to add the menu to the app. For that, open &lt;code class=&quot;highlighter-rouge&quot;&gt;app/app.html&lt;/code&gt; and replace code with this code&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ion-menu [content]=&quot;content&quot;&amp;gt;
    &amp;lt;ion-header&amp;gt;
        &amp;lt;ion-toolbar&amp;gt;
            &amp;lt;ion-title&amp;gt;Menu&amp;lt;/ion-title&amp;gt;
        &amp;lt;/ion-toolbar&amp;gt;
    &amp;lt;/ion-header&amp;gt;

    &amp;lt;ion-content&amp;gt;
        &amp;lt;ion-list&amp;gt;
            &amp;lt;button menuClose ion-item *ngFor=&quot;let p of pages&quot; (click)=&quot;openPage(p)&quot;&amp;gt;
        
      &amp;lt;/button&amp;gt;
        &amp;lt;/ion-list&amp;gt;
    &amp;lt;/ion-content&amp;gt;

&amp;lt;/ion-menu&amp;gt;

&amp;lt;!-- Disable swipe-to-go-back because it's poor UX to combine STGB with side menus --&amp;gt;
&amp;lt;ion-nav [root]=&quot;rootPage&quot; #content swipeBackEnabled=&quot;false&quot;&amp;gt;&amp;lt;/ion-nav&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now, we need to add the reference to the menu in the application pages. Open &lt;code class=&quot;highlighter-rouge&quot;&gt;pages/beers/beers.html&lt;/code&gt; and add this code at the beginning of the page&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ion-header&amp;gt;
    &amp;lt;ion-navbar&amp;gt;
        &amp;lt;button ion-button menuToggle&amp;gt;
      &amp;lt;ion-icon name=&quot;menu&quot;&amp;gt;&amp;lt;/ion-icon&amp;gt;
    &amp;lt;/button&amp;gt;
        &amp;lt;ion-title&amp;gt;Ionic 2 Beers Gallery&amp;lt;/ion-title&amp;gt;
    &amp;lt;/ion-navbar&amp;gt;
&amp;lt;/ion-header&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Do the same for &lt;code class=&quot;highlighter-rouge&quot;&gt;pages/home/home.html&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;app/app.component.ts&lt;/code&gt; and add this code in the constructor&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    this.pages = [
      { title: 'Home', component: HomePage },
      { title: 'Beers list', component: BeersPage }
    ];
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;And add&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  openPage(page) {
    // Reset the content nav to have just this page
    // we wouldn't want the back button to show in this scenario
    this.nav.setRoot(page.component);
  }
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Save changes and run the app. It should look this way.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;../img/2017-01-21-getBeersList.png&quot; alt=&quot;Get beers list&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;fetching-data-from-beer-catalog&quot;&gt;Fetching data from Beer catalog&lt;/h2&gt;

&lt;p&gt;In the first step, we load beers catalog in a static page. Now, we load this catalog from the controller.
First, open &lt;code class=&quot;highlighter-rouge&quot;&gt;pages/beers/beers.ts&lt;/code&gt; and add the code in the constructor&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;this.beers = [
  {
    alcohol: 8.5,
    name: 'Affligem Tripel',
    description: 'The king of the abbey beers. It is amber-gold and pours with a deep head and original aroma, delivering a complex, full bodied flavour. Pure enjoyment! Secondary fermentation in the bottle.'
  },
  {
    alcohol: 9.2,
    name: 'Rochefort 8',
    description: 'A dry but rich flavoured beer with complex fruity and spicy flavours.'
  },
  {
    alcohol: 7,
    name: 'Chimay Rouge',
    description: 'This Trappist beer possesses a beautiful coppery colour that makes it particularly attractive. Topped with a creamy head, it gives off a slight fruity apricot smell from the fermentation. The aroma felt in the mouth is a balance confirming the fruit nuances revealed to the sense of smell. This traditional Belgian beer is best savoured at cellar temperature.'
  }
];
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Then open &lt;code class=&quot;highlighter-rouge&quot;&gt;pages/beers/beers.html&lt;/code&gt; and modify the display list construction like this&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ul&amp;gt;
    &amp;lt;li *ngFor=&quot;let beer of beers&quot;&amp;gt;
        &amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;
        &amp;lt;p&amp;gt;
            
        &amp;lt;/p&amp;gt;
    &amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;Total number of beers: &amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;translate-labels&quot;&gt;Translate labels&lt;/h2&gt;

&lt;p&gt;Now the application needs to be translated for users all around the world. For this, add &lt;code class=&quot;highlighter-rouge&quot;&gt;ng2-translate&lt;/code&gt; library with this command and update bower configuration&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm install ng2-translate --save
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;app/app.component.ts&lt;/code&gt; file  and add&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import { TranslateService } from 'ng2-translate/ng2-translate';
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;and add parameter to the constructor&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;constructor(translate: TranslateService, public platform: Platform) {
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;and set default language in the constructor&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;// set default language
translate.setDefaultLang('en');
translate.use(translate.getBrowserLang());
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Create new files that contain translated labels in a new directory &lt;code class=&quot;highlighter-rouge&quot;&gt;i18n&lt;/code&gt; in &lt;code class=&quot;highlighter-rouge&quot;&gt;assets&lt;/code&gt; directory, for example &lt;code class=&quot;highlighter-rouge&quot;&gt;en.json&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;menu&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Menu&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;home&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Home&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;beersList&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;List of beers&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;beerGallery&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Ionic Beer Gallery&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;beersNumbers&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Total number of beers&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Welcome!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;ionicBeers&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Ionic Beers&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Update &lt;code class=&quot;highlighter-rouge&quot;&gt;pages/home/home.html&lt;/code&gt; file to translate labels&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;content
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Change all labels in &lt;code class=&quot;highlighter-rouge&quot;&gt;*.html&lt;/code&gt; files to translate labels&lt;/p&gt;

&lt;h2 id=&quot;order-and-search-in-list&quot;&gt;Order and search in list&lt;/h2&gt;

&lt;p&gt;Sometimes the list need to be ordered. Angular do this with easy directives.&lt;/p&gt;

&lt;p&gt;We need to create a new provider with Ionic CLI&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ionic g provider Data
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;app/app.module.ts&lt;/code&gt; and add&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import { Data } from '../providers/data';
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;In &lt;code class=&quot;highlighter-rouge&quot;&gt;@NgModule&lt;/code&gt; add the definition of the provider&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}, Data]
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;providers/data.ts&lt;/code&gt; file and add in the Data class&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  beers: Array&amp;lt;{alcohol: number, name: string, description: string}&amp;gt;;

  constructor(public http: Http) {
    this.beers = [
      {
        alcohol: 8.5,
        name: 'Affligem Tripel',
        description: 'The king of the abbey beers. It is amber-gold and pours with a deep head and original aroma, delivering a complex, full bodied flavour. Pure enjoyment! Secondary fermentation in the bottle.'
      },
      {
        alcohol: 9.2,
        name: 'Rochefort 8',
        description: 'A dry but rich flavoured beer with complex fruity and spicy flavours.'
      },
      {
        alcohol: 7,
        name: 'Chimay Rouge',
        description: 'This Trappist beer possesses a beautiful coppery colour that makes it particularly attractive. Topped with a creamy head, it gives off a slight fruity apricot smell from the fermentation. The aroma felt in the mouth is a balance confirming the fruit nuances revealed to the sense of smell. This traditional Belgian beer is best savoured at cellar temperature.'
      }
    ];
  }

  filterBeers(searchTerm) {
    return this.beers.filter((beer) =&amp;gt; {
      return beer.name.toLowerCase().indexOf(searchTerm.toLowerCase()) &amp;gt; -1;
    });
  }
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;In &lt;code class=&quot;highlighter-rouge&quot;&gt;beers/beers.ts&lt;/code&gt; file import the provider Data&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;import { Data } from '../../providers/data';
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;and replace the beers definition&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  searchTerm: string = '';
  beers: any;
  listSize: number;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Remove the initialization of the beers list in the constructor and define the filtered function&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  setFilteredBeers() {
    this.beers = this.dataService.filterBeers(this.searchTerm);
  }
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;beers/beers.html&lt;/code&gt; and add lines to filter beers&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;div&amp;gt;
    &amp;lt;ion-searchbar [(ngModel)]=&quot;searchTerm&quot; (ionInput)=&quot;setFilteredBeers()&quot;&amp;gt;&amp;lt;/ion-searchbar&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Replace the code for the list size&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;p&amp;gt;beersNumbers : &amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;loading-beers-from-json-files&quot;&gt;Loading beers from JSON files&lt;/h2&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;providers/data.ts&lt;/code&gt; and replace the code in the constructor&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    this.getJsonData().subscribe(data =&amp;gt; {
      this.beers = data;
    });
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;and create a new function&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  getJsonData() {
    return this.http.get('../assets/beers/beers.json').map(res =&amp;gt; res.json());
  }
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;pages/beers/beers.ts&lt;/code&gt; and create a new function&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  getData() {
    this.dataService.getJsonData().subscribe(result =&amp;gt; {
      this.beers = result;
      this.listSize = this.beers.length;
    });
  }
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;and add the call of the function in &lt;code class=&quot;highlighter-rouge&quot;&gt;ionViewDidLoad&lt;/code&gt; function.&lt;/p&gt;

&lt;h2 id=&quot;getting-the-beers-pics&quot;&gt;Getting the beers pics&lt;/h2&gt;

&lt;p&gt;We can also extract the image URL from the received JSON and then we add the image to the &lt;code class=&quot;highlighter-rouge&quot;&gt;pages/beers/beers.html&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;a href=&quot;#/assets/beers/&quot;&amp;gt;
    &amp;lt;ion-img src=&quot;&quot; class=&quot;thumb-img&quot;&amp;gt;&amp;lt;/ion-img&amp;gt;
&amp;lt;/a&amp;gt;
&amp;lt;div class=&quot;thumb&quot;&amp;gt;
    &amp;lt;a href=&quot;#/beers/&quot;&amp;gt;&amp;lt;/a&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;../img/2017-01-21-beers-pics.png&quot; alt=&quot;After adding pics&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;lets-display-the-beer-description&quot;&gt;Let’s display the beer description&lt;/h2&gt;

&lt;p&gt;On the beers list &lt;code class=&quot;highlighter-rouge&quot;&gt;listBeers.html&lt;/code&gt;, add action on beer name and on picture&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;img ng-src=&quot;&quot; class=&quot;thumb-img&quot; ng-click=&quot;openModal(beer.id)&quot;&amp;gt;
&amp;lt;a href=&quot;&quot; ng-click=&quot;openModal(beer.id)&quot;&amp;gt;&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now create new file &lt;code class=&quot;highlighter-rouge&quot;&gt;beer-detail.html&lt;/code&gt; to display beer description&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ion-modal-view&amp;gt;
	&amp;lt;ion-header-bar align-title=&quot;left&quot; class=&quot;bar-calm&quot;&amp;gt;
		&amp;lt;h1 class =&quot;title&quot;&amp;gt;&amp;lt;/h1&amp;gt;
		&amp;lt;button class=&quot;button icon ion-close&quot; ng-click=&quot;closeModal()&quot;&amp;gt;&amp;lt;/button&amp;gt;
	&amp;lt;/ion-header-bar&amp;gt;

	&amp;lt;ion-content&amp;gt;
		&amp;lt;img ng-src=&quot;&quot; class=&quot;beer&quot;&amp;gt;
		&amp;lt;p class=&quot;description&quot;&amp;gt;&amp;lt;/p&amp;gt;

		&amp;lt;ul class=&quot;beer-thumbs&quot;&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;img ng-src=&quot;&quot; ng-click=&quot;setImage(beer.img)&quot;&amp;gt;
		  &amp;lt;/li&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;img ng-src=&quot;&quot; ng-click=&quot;setImage(beer.label)&quot;&amp;gt;
		  &amp;lt;/li&amp;gt;
		&amp;lt;/ul&amp;gt;

		&amp;lt;ul class=&quot;specs&quot;&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;dl&amp;gt;
		      &amp;lt;dt&amp;gt;alcoholContent&amp;lt;/dt&amp;gt;
		      &amp;lt;dd&amp;gt;&amp;lt;/dd&amp;gt;
		    &amp;lt;/dl&amp;gt;
		  &amp;lt;/li&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;dl&amp;gt;
		      &amp;lt;dt&amp;gt;brewery&amp;lt;/dt&amp;gt;
		      &amp;lt;dd&amp;gt;&amp;lt;/dd&amp;gt;
		    &amp;lt;/dl&amp;gt;
		  &amp;lt;/li&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;dl&amp;gt;
		      &amp;lt;dt&amp;gt;availability&amp;lt;/dt&amp;gt;
		      &amp;lt;dd&amp;gt;&amp;lt;/dd&amp;gt;
		    &amp;lt;/dl&amp;gt;
		  &amp;lt;/li&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;dl&amp;gt;
		      &amp;lt;dt&amp;gt;style&amp;lt;/dt&amp;gt;
		      &amp;lt;dd&amp;gt;&amp;lt;/dd&amp;gt;
		    &amp;lt;/dl&amp;gt;
		  &amp;lt;/li&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;dl&amp;gt;
		      &amp;lt;dt&amp;gt;serving&amp;lt;/dt&amp;gt;
		      &amp;lt;dd&amp;gt;&amp;lt;/dd&amp;gt;
		    &amp;lt;/dl&amp;gt;
		  &amp;lt;/li&amp;gt;
		&amp;lt;/ul&amp;gt;
	&amp;lt;/ion-content&amp;gt;
&amp;lt;/ion-modal-view&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Define modal to display beer detail in &lt;code class=&quot;highlighter-rouge&quot;&gt;controllers.js&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ionicModal.fromTemplateUrl('templates/beer-detail.html', {
  scope: $scope,
  animation: 'slide-in-up'
}).then(function(modal) {
  $scope.beerModal = modal;
});
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Load beer definition from JSON file in &lt;code class=&quot;highlighter-rouge&quot;&gt;controllers.js&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$scope.openModal = function(beerId) {
  $http.get('beers/' + beerId + '.json').success(function(data) {
    $scope.beer = data;      
    $scope.mainImg = $scope.beer.img;

    $scope.setImage = function(img) {
      $scope.mainImg = img;
    }
  });
  myBeerId = beerId;
  $scope.beerModal.show();
};
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Hide modal when click on close button in &lt;code class=&quot;highlighter-rouge&quot;&gt;controllers.js&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$scope.closeModal = function() {
  $scope.beerModal.hide();
};

$scope.$on('$destroy', function() {
  $scope.beerModal.remove();
});
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;2015-12-04-beer-detail.png&quot; alt=&quot;After display beer detail&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 21 Jan 2017 00:00:00 +0000</pubDate>
        <link>http://www.beer-tutorials.orghttp://www.beer-tutorials.org/2017/01/21/Ionic2-Beers/</link>
        <guid isPermaLink="true">http://www.beer-tutorials.orghttp://www.beer-tutorials.org/2017/01/21/Ionic2-Beers/</guid>
        
        
      </item>
    
      <item>
        <title>Ionic Beers</title>
        <description>&lt;h1 id=&quot;ionic-beers&quot;&gt;Ionic Beers&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Ionic Beers&lt;/strong&gt; is a tutorial of the &lt;a href=&quot;http://www.beer-tutorials.org&quot;&gt;Beer Tutorials&lt;/a&gt; series.
In this tutorial we will create a simple app that queries a beer catalog and displays a list of beers.&lt;/p&gt;

&lt;h2 id=&quot;getting-started&quot;&gt;Getting Started&lt;/h2&gt;

&lt;p&gt;Install &lt;a href=&quot;https://nodejs.org/&quot;&gt;NodeJS&lt;/a&gt; and then using the node package manager (npm), install ionic.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;npm install -g ionic
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After installing ionic, create a new project called &lt;code class=&quot;highlighter-rouge&quot;&gt;ionic-beers&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ionic start ionic-beers blank
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Navigate to the project directory and add the mobile development platform.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ionic platform add android
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Run the application on the Android emulator.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ionic emulate android
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Run the application on desktop browser
&lt;code class=&quot;highlighter-rouge&quot;&gt;
ionic serve --lab
&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Note: To run the application in the Android emulator, you need to have the Android SDK
installed and configured on your computer.
The easiest way to do it is to install &lt;a href=&quot;http://developer.android.com/tools/studio/index.html&quot;&gt;Android Studio&lt;/a&gt;
for your platform.&lt;/p&gt;

  &lt;p&gt;If you have issues while initializing the app, read carefully &lt;a href=&quot;http://ionicframework.com/docs/getting-help/&quot;&gt;these instructions&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;/img/2015-12-04-initial-app.png&quot; alt=&quot;Initial app&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;project-structure&quot;&gt;Project Structure&lt;/h2&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;.
└── ionic-beers
    ├── www
    │   ├── css
    │   │   └── style.css
    │   ├── img
    │   │   └── ionic.png
    │   ├── js  
    │   │   └── app.js
    │   ├── lib
    │   │   └── ionic
    │   │       └── ...
    │   └── index.html
    ├── hooks
    │   ├── after_prepare
    │   │   └── ...
    │   └── README.md
    ├── resources
    │   ├── android
    │   │   └── ...
    │   ├── ios
    │   │   └── ...
    │   ├── icon.png
    │   └── splash.png
    ├── scss
    │   └── ionic.app.scss
    ├── package.json
    ├── bower.json
    ├── config.xml
    ├── gulpfile.js
    ├── ionic.project
    └── platforms
        ├── android
        └── ios    
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Inside  the project folder there are 4 sub-folders: &lt;code class=&quot;highlighter-rouge&quot;&gt;hooks&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;scss&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;platforms&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;www&lt;/code&gt;. The application source code resides in the &lt;code class=&quot;highlighter-rouge&quot;&gt;www&lt;/code&gt; folder. Application code is written using AngularJS and Javascript.&lt;/p&gt;

&lt;p&gt;Inside the &lt;code class=&quot;highlighter-rouge&quot;&gt;www&lt;/code&gt; folder is a file called &lt;code class=&quot;highlighter-rouge&quot;&gt;index.html&lt;/code&gt; which has the default application code. Finally &lt;code class=&quot;highlighter-rouge&quot;&gt;app.js&lt;/code&gt; contains the code to start the application with the defined modules.&lt;/p&gt;

&lt;h2 id=&quot;designing-the-app&quot;&gt;Designing the app&lt;/h2&gt;

&lt;p&gt;Let’s start by removing unused lines in application. Open &lt;code class=&quot;highlighter-rouge&quot;&gt;index.html&lt;/code&gt; and look at the default code. Remove lines between the &lt;code class=&quot;highlighter-rouge&quot;&gt;body&lt;/code&gt; tags. The &lt;code class=&quot;highlighter-rouge&quot;&gt;body&lt;/code&gt; tag has an attribute called &lt;code class=&quot;highlighter-rouge&quot;&gt;ng-app&lt;/code&gt; which references the application.&lt;/p&gt;

&lt;p&gt;This project will use a &lt;em&gt;&lt;a href=&quot;http://ionicframework.com/docs/api/directive/ionNavView/&quot;&gt;navigation view&lt;/a&gt;&lt;/em&gt; to design our app.&lt;/p&gt;

&lt;p&gt;Inside the body tag add the navigation view.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ion-nav-view&amp;gt;&amp;lt;/ion-nav-view&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Create a new directory in the &lt;code class=&quot;highlighter-rouge&quot;&gt;www&lt;/code&gt; directory named &lt;code class=&quot;highlighter-rouge&quot;&gt;templates&lt;/code&gt;. In this new directory, create a new file named &lt;code class=&quot;highlighter-rouge&quot;&gt;menu.html&lt;/code&gt;. In this file, you would use a &lt;em&gt;ion-menu&lt;/em&gt; directive. Open &lt;code class=&quot;highlighter-rouge&quot;&gt;menu.html&lt;/code&gt; and add lines&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ion-side-menus&amp;gt;
  &amp;lt;ion-side-menu-content&amp;gt;
    &amp;lt;ion-nav-bar class=&quot;bar-dark&quot;&amp;gt;
      &amp;lt;ion-nav-back-button&amp;gt;&amp;lt;/ion-nav-back-button&amp;gt;

      &amp;lt;ion-nav-buttons side=&quot;left&quot;&amp;gt;
        &amp;lt;button class=&quot;button button-icon button-clear ion-navicon&quot; menu-toggle=&quot;left&quot;&amp;gt;&amp;lt;/button&amp;gt;
      &amp;lt;/ion-nav-buttons&amp;gt;
    &amp;lt;/ion-nav-bar&amp;gt;

    &amp;lt;ion-nav-view name=&quot;menuContent&quot;&amp;gt;&amp;lt;/ion-nav-view&amp;gt;
  &amp;lt;/ion-side-menu-content&amp;gt;

  &amp;lt;ion-side-menu side=&quot;left&quot;&amp;gt;
    &amp;lt;ion-header-bar class=&quot;bar-dark&quot;&amp;gt;
      &amp;lt;h1 class=&quot;title&quot;&amp;gt;Menu&amp;lt;/h1&amp;gt;
    &amp;lt;/ion-header-bar&amp;gt;

		&amp;lt;ion-content&amp;gt;
			&amp;lt;ul class=&quot;list&quot;&amp;gt;
				&amp;lt;a href=&quot;#/event/home&quot; class=&quot;item&quot; menu-close&amp;gt;Home&amp;lt;/a&amp;gt;
				&amp;lt;a href=&quot;#/event/beers&quot; class=&quot;item&quot; menu-close&amp;gt;Beers list&amp;lt;/a&amp;gt;
			&amp;lt;/ul&amp;gt;
		&amp;lt;/ion-content&amp;gt;
  &amp;lt;/ion-side-menu&amp;gt;
&amp;lt;/ion-side-menus&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Create a new file in &lt;code class=&quot;highlighter-rouge&quot;&gt;templates&lt;/code&gt;directory named &lt;code class=&quot;highlighter-rouge&quot;&gt;home.html&lt;/code&gt;. Open &lt;code class=&quot;highlighter-rouge&quot;&gt;home.html&lt;/code&gt; and add lines&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ion-view view-title=&quot;Ionic Beers&quot;&amp;gt;
	&amp;lt;ion-content class=&quot;padding&quot;&amp;gt;
		Welcome!
	&amp;lt;/ion-content&amp;gt;
&amp;lt;/ion-view&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Create a new file in &lt;code class=&quot;highlighter-rouge&quot;&gt;templates&lt;/code&gt; directory called &lt;code class=&quot;highlighter-rouge&quot;&gt;listBeers.html&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ion-view view-title=&quot;Ionic Beer Gallery&quot;&amp;gt;
	&amp;lt;ion-content class=&quot;padding&quot;&amp;gt;
		&amp;lt;ul&amp;gt;
	      &amp;lt;li&amp;gt;
	        &amp;lt;span&amp;gt;Affligem Blond&amp;lt;/span&amp;gt;
	        &amp;lt;p&amp;gt;
	          Affligem Blonde, the classic clear blonde abbey ale, with a gentle roundness and 6.8% alcohol.
	          Low on bitterness, it is eminently drinkable.
	        &amp;lt;/p&amp;gt;
	      &amp;lt;/li&amp;gt;
	      &amp;lt;li&amp;gt;
	        &amp;lt;span&amp;gt;Affligem Tripel&amp;lt;/span&amp;gt;
	        &amp;lt;p&amp;gt;
	          The king of the abbey beers. It is amber-gold and pours with a deep head and original aroma,
	          delivering a complex, full bodied flavour. Pure enjoyment! Secondary fermentation in the bottle.
	        &amp;lt;/p&amp;gt;
	      &amp;lt;/li&amp;gt;
	    &amp;lt;/ul&amp;gt;

		&amp;lt;p&amp;gt;Total number of beers: 2&amp;lt;/p&amp;gt;
  &amp;lt;/ion-content&amp;gt;
&amp;lt;/ion-view&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;app.js&lt;/code&gt; to define routes&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;.config(function ($stateProvider, $urlRouterProvider) {

    $stateProvider
    .state('eventmenu', {
      url: '/event',
      abstract: 'true',
      templateUrl: 'templates/menu.html'
    })
    .state('eventmenu.home', {
        url: '/home',
        views: {
          'menuContent': {
            templateUrl: 'templates/home.html'
          }
        }
    })
    .state('eventmenu.beers', {
        url: '/beers',
        views: {
          'menuContent': {
            templateUrl: 'templates/listBeers.html'
          }
        }
    });

    $urlRouterProvider.otherwise('/event/home');
})
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Save changes and run the app. It should look this way.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2015-12-04-getBeersList.png&quot; alt=&quot;Get beers list&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;fetching-data-from-beer-catalog&quot;&gt;Fetching data from Beer catalog&lt;/h2&gt;

&lt;p&gt;Create a new file &lt;code class=&quot;highlighter-rouge&quot;&gt;js&lt;/code&gt; directory called &lt;code class=&quot;highlighter-rouge&quot;&gt;controllers.js&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;angular.module('ionicbeers')

.controller('BeersCtrl', ['$scope', function($scope) {
    $scope.beers = [
      {
        &quot;alcohol&quot;: 8.5,
        &quot;name&quot;: &quot;Affligem Tripel&quot;,
        &quot;description&quot;: &quot;The king of the abbey beers. It is amber-gold and pours with a deep head and original aroma, delivering a complex, full bodied flavour. Pure enjoyment! Secondary fermentation in the bottle.&quot;
      },
      {
        &quot;alcohol&quot;: 9.2,
        &quot;name&quot;: &quot;Rochefort 8&quot;,
        &quot;description&quot;: &quot;A dry but rich flavoured beer with complex fruity and spicy flavours.&quot;
      },
      {
        &quot;alcohol&quot;: 7,
        &quot;name&quot;: &quot;Chimay Rouge&quot;,
        &quot;description&quot;: &quot;This Trappist beer possesses a beautiful coppery colour that makes it particularly attractive. Topped with a creamy head, it gives off a slight fruity apricot smell from the fermentation. The aroma felt in the mouth is a balance confirming the fruit nuances revealed to the sense of smell. This traditional Belgian beer is best savoured at cellar temperature &quot;
      }
    ];
  }])
  ```

This controller defines a list of beers returned to the Angular scope.

Open `index.html` and and declare the new controller


&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;script src=&quot;js/controllers.js&quot;&gt;&lt;/script&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;

Open `app.js` file and add the BeersCtrl to the beer menu item

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;.state(‘eventmenu.beers’, {
    url: ‘/beers’,
    views: {
      ‘menuContent’: {
        templateUrl: ‘templates/listBeers.html’,
        controller: ‘BeersCtrl’
      }
    }
});
```&lt;/p&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;listBeers.html&lt;/code&gt; and replace lines between &lt;code class=&quot;highlighter-rouge&quot;&gt;ion-content&lt;/code&gt; tag with those lines&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ul class=&quot;list&quot;&amp;gt;
    &amp;lt;li ng-repeat=&quot;beer in beers&quot;&amp;gt;
      &amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;
      &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

&amp;lt;p&amp;gt;Total number of beers: &amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;translate-labels&quot;&gt;Translate labels&lt;/h2&gt;

&lt;p&gt;Now the application needs to be translated for users all around the world. For this, add &lt;code class=&quot;highlighter-rouge&quot;&gt;angular-translate&lt;/code&gt; library with this command and update bower configuration&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;bower install angular-translate-loader-static-files --save
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;app.js&lt;/code&gt; file  and update&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;angular.module('ionicbeers', ['ionic','pascalprecht.translate'])
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;and add lines after &lt;code class=&quot;highlighter-rouge&quot;&gt;$urlRouterProvider&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;// Translate labels / title / menus
$translateProvider.useSanitizeValueStrategy('escape');
$translateProvider.useStaticFilesLoader({
    prefix: 'languages/',
    suffix:'.json'
});
$translateProvider
.registerAvailableLanguageKeys(['en','fr'], {
    'en_US': 'en',
    'en_UK': 'en',
    'fr_FR': 'fr',
    'fr_BE': 'fr'
})
.determinePreferredLanguage();

$translateProvider.use();
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;index.html&lt;/code&gt; and add lines to link script&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;script src=&quot;lib/angular-translate/angular-translate.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src=&quot;lib/angular-translate-loader-static-files/angular-translate-loader-static-files.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Create new files that contain translated labels in a new directory &lt;code class=&quot;highlighter-rouge&quot;&gt;languages&lt;/code&gt;, for example &lt;code class=&quot;highlighter-rouge&quot;&gt;en.json&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;menu&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Menu&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;home&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Home&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;beersList&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;List of beers&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;beerGallery&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Ionic Beer Gallery&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;beersNumbers&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Total number of beers&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;content&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Welcome!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
	&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&quot;ionicBeers&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Ionic Beers&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Update &lt;code class=&quot;highlighter-rouge&quot;&gt;home.html&lt;/code&gt; file to translate labels&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;content
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Change all labels in &lt;code class=&quot;highlighter-rouge&quot;&gt;*.html&lt;/code&gt; files to translate labels&lt;/p&gt;

&lt;h2 id=&quot;order-and-search-in-list&quot;&gt;Order and search in list&lt;/h2&gt;

&lt;p&gt;Sometimes the list need to be ordered. AngularJS do this with easy directives.&lt;/p&gt;

&lt;p&gt;Add lines in &lt;code class=&quot;highlighter-rouge&quot;&gt;controllers.js&lt;/code&gt; file  after beers list initialization&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$scope.orderProp = 'alcohol';
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Open &lt;code class=&quot;highlighter-rouge&quot;&gt;listBeers.html&lt;/code&gt; and add lines to filter beers&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;div&amp;gt;
  search: &amp;lt;input ng-model=&quot;query&quot;&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Add lines to sort beers&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;div&amp;gt;
  sortBy:
  &amp;lt;select ng-model=&quot;orderProp&quot;&amp;gt;
    &amp;lt;option value=&quot;name&quot;&amp;gt;alphabetical&amp;lt;/option&amp;gt;
    &amp;lt;option value=&quot;alcohol&quot;&amp;gt;alcoholContent&amp;lt;/option&amp;gt;
  &amp;lt;/select&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After, add filter and sorter to the &lt;code class=&quot;highlighter-rouge&quot;&gt;ng-repeat&lt;/code&gt; directive&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;li ng-repeat=&quot;beer in beers | filter:query | orderBy:orderProp&quot;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;loading-beers-from-json-files&quot;&gt;Loading beers from JSON files&lt;/h2&gt;

&lt;p&gt;Add &lt;code class=&quot;highlighter-rouge&quot;&gt;$http&lt;/code&gt; service in the controller definition and replace initialization of beers list  with loading JSON files&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$http.get('beers/beers.json').success(function(data) {
  $scope.beers = data;
});
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;getting-the-beers-pics&quot;&gt;Getting the beers pics&lt;/h2&gt;

&lt;p&gt;We can also extract the image URL from the received JSON and then we add the image to the &lt;code class=&quot;highlighter-rouge&quot;&gt;listBeers.html&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;a href=&quot;#/beers/&quot;&amp;gt;&amp;lt;img ng-src=&quot;&quot; class=&quot;thumb-img&quot;&amp;gt;&amp;lt;/a&amp;gt;
&amp;lt;div class=&quot;thumb&quot;&amp;gt;
&amp;lt;a href=&quot;#/beers/&quot;&amp;gt;&amp;lt;/a&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/img/2015-12-04-beers-pics.png&quot; alt=&quot;After adding pics&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;lets-display-the-beer-description&quot;&gt;Let’s display the beer description&lt;/h2&gt;

&lt;p&gt;On the beers list &lt;code class=&quot;highlighter-rouge&quot;&gt;listBeers.html&lt;/code&gt;, add action on beer name and on picture&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;img ng-src=&quot;&quot; class=&quot;thumb-img&quot; ng-click=&quot;openModal(beer.id)&quot;&amp;gt;
&amp;lt;a href=&quot;&quot; ng-click=&quot;openModal(beer.id)&quot;&amp;gt;&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now create new file &lt;code class=&quot;highlighter-rouge&quot;&gt;beer-detail.html&lt;/code&gt; to display beer description&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ion-modal-view&amp;gt;
	&amp;lt;ion-header-bar align-title=&quot;left&quot; class=&quot;bar-calm&quot;&amp;gt;
		&amp;lt;h1 class =&quot;title&quot;&amp;gt;&amp;lt;/h1&amp;gt;
		&amp;lt;button class=&quot;button icon ion-close&quot; ng-click=&quot;closeModal()&quot;&amp;gt;&amp;lt;/button&amp;gt;
	&amp;lt;/ion-header-bar&amp;gt;

	&amp;lt;ion-content&amp;gt;
		&amp;lt;img ng-src=&quot;&quot; class=&quot;beer&quot;&amp;gt;
		&amp;lt;p class=&quot;description&quot;&amp;gt;&amp;lt;/p&amp;gt;

		&amp;lt;ul class=&quot;beer-thumbs&quot;&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;img ng-src=&quot;&quot; ng-click=&quot;setImage(beer.img)&quot;&amp;gt;
		  &amp;lt;/li&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;img ng-src=&quot;&quot; ng-click=&quot;setImage(beer.label)&quot;&amp;gt;
		  &amp;lt;/li&amp;gt;
		&amp;lt;/ul&amp;gt;

		&amp;lt;ul class=&quot;specs&quot;&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;dl&amp;gt;
		      &amp;lt;dt&amp;gt;alcoholContent&amp;lt;/dt&amp;gt;
		      &amp;lt;dd&amp;gt;&amp;lt;/dd&amp;gt;
		    &amp;lt;/dl&amp;gt;
		  &amp;lt;/li&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;dl&amp;gt;
		      &amp;lt;dt&amp;gt;brewery&amp;lt;/dt&amp;gt;
		      &amp;lt;dd&amp;gt;&amp;lt;/dd&amp;gt;
		    &amp;lt;/dl&amp;gt;
		  &amp;lt;/li&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;dl&amp;gt;
		      &amp;lt;dt&amp;gt;availability&amp;lt;/dt&amp;gt;
		      &amp;lt;dd&amp;gt;&amp;lt;/dd&amp;gt;
		    &amp;lt;/dl&amp;gt;
		  &amp;lt;/li&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;dl&amp;gt;
		      &amp;lt;dt&amp;gt;style&amp;lt;/dt&amp;gt;
		      &amp;lt;dd&amp;gt;&amp;lt;/dd&amp;gt;
		    &amp;lt;/dl&amp;gt;
		  &amp;lt;/li&amp;gt;
		  &amp;lt;li&amp;gt;
		    &amp;lt;dl&amp;gt;
		      &amp;lt;dt&amp;gt;serving&amp;lt;/dt&amp;gt;
		      &amp;lt;dd&amp;gt;&amp;lt;/dd&amp;gt;
		    &amp;lt;/dl&amp;gt;
		  &amp;lt;/li&amp;gt;
		&amp;lt;/ul&amp;gt;
	&amp;lt;/ion-content&amp;gt;
&amp;lt;/ion-modal-view&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Define modal to display beer detail in &lt;code class=&quot;highlighter-rouge&quot;&gt;controllers.js&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ionicModal.fromTemplateUrl('templates/beer-detail.html', {
  scope: $scope,
  animation: 'slide-in-up'
}).then(function(modal) {
  $scope.beerModal = modal;
});
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Load beer definition from JSON file in &lt;code class=&quot;highlighter-rouge&quot;&gt;controllers.js&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$scope.openModal = function(beerId) {
  $http.get('beers/' + beerId + '.json').success(function(data) {
    $scope.beer = data;      
    $scope.mainImg = $scope.beer.img;

    $scope.setImage = function(img) {
      $scope.mainImg = img;
    }
  });
  myBeerId = beerId;
  $scope.beerModal.show();
};
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Hide modal when click on close button in &lt;code class=&quot;highlighter-rouge&quot;&gt;controllers.js&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$scope.closeModal = function() {
  $scope.beerModal.hide();
};

$scope.$on('$destroy', function() {
  $scope.beerModal.remove();
});
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/img/2015-12-04-beer-detail.png&quot; alt=&quot;After display beer detail&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 05 Dec 2015 00:00:00 +0000</pubDate>
        <link>http://www.beer-tutorials.orghttp://www.beer-tutorials.org/2015/12/05/Ionic-Beers/</link>
        <guid isPermaLink="true">http://www.beer-tutorials.orghttp://www.beer-tutorials.org/2015/12/05/Ionic-Beers/</guid>
        
        
      </item>
    
      <item>
        <title>NativeScript Beers</title>
        <description>&lt;p&gt;&lt;strong&gt;NativeScript Beers&lt;/strong&gt; is a tutorial of the &lt;a href=&quot;http://www.beer-tutorials.org&quot;&gt;Beer Tutorials&lt;/a&gt; series.
In this tutorial we will create a simple app that queries a beer catalog and displays a list of beers.&lt;/p&gt;

&lt;h2 id=&quot;getting-started&quot;&gt;Getting Started&lt;/h2&gt;

&lt;p&gt;Install &lt;a href=&quot;https://nodejs.org/&quot;&gt;NodeJS&lt;/a&gt; and then using the node package manager (npm), install native script.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    npm install -g nativescript
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;After installing native script, create a new project called &lt;code class=&quot;highlighter-rouge&quot;&gt;nativescript-beers&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    tns create nativescript-beers
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Navigate to the project directory and add the mobile development platform.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    tns platform add android
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Run the application on the Android emulator.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    tns run android --emulator
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;Note: To run the application in the Android emulator, you need to have the Android SDK
installed and configured on your computer.
The easiest way to do it is to install &lt;a href=&quot;http://developer.android.com/tools/studio/index.html&quot;&gt;Android Studio&lt;/a&gt;
for your platform.&lt;/p&gt;

  &lt;p&gt;If you find issues while initializing the app, read carefully &lt;a href=&quot;http://docs.nativescript.org/setup/ns-cli-setup/&quot;&gt;these instructions&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;/img/2015-12-01-initial-app.png&quot; alt=&quot;Initial app&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;tns livesync&lt;/code&gt; command instantly transfers XML, CSS, and JavaScript files to a running NativeScript app. If you set the command’s &lt;code class=&quot;highlighter-rouge&quot;&gt;--watch&lt;/code&gt; flag (&lt;code class=&quot;highlighter-rouge&quot;&gt;tns livesync ios --emulator --watch&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;tns livesync android --emulator --watch&lt;/code&gt;), the NativeScript CLI will watch your app for changes, and apply those changes automatically after you save files. Be warned, however, that the &lt;code class=&quot;highlighter-rouge&quot;&gt;livesync&lt;/code&gt; command currently does not show &lt;code class=&quot;highlighter-rouge&quot;&gt;console.log()&lt;/code&gt; output or stack traces. So during debugging you may want to switch back to &lt;code class=&quot;highlighter-rouge&quot;&gt;tns run&lt;/code&gt; or use &lt;code class=&quot;highlighter-rouge&quot;&gt;adb logcat&lt;/code&gt; in parallel to get logs directly from the android emulator.&lt;/p&gt;

&lt;h2 id=&quot;project-structure&quot;&gt;Project Structure&lt;/h2&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;.
└── nativescript-beers
    ├── app
    │   ├── App_Resources
    │   │   ├── Android
    │   │   └── iOS
    │   ├──  main-page.js
    │   ├──  main-page.xml  
    │   ├──  main-view-model.js  
    │   ├──  package.json  
    │   ├──  references.d.ts
    │   ├── app.css
    │   ├── app.js
    │   └── ...
    ├── node_modules
    │   └── tns-core-modules
    ├── package.json
    └── platforms
        ├── android
        └── ios    
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Inside  the project folder there are 3 sub-folders: &lt;code class=&quot;highlighter-rouge&quot;&gt;app&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;node_modules&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;platforms&lt;/code&gt; :&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;app&lt;/code&gt;: This folder contains all the development resources you need to build your app. You’ll be spending most of your time editing the files in here.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;node_modules&lt;/code&gt;: This folder contains your app’s npm module dependencies. All new NativeScript projects start with a single dependency on tns-core-modules.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;node_modules/tns-core-modules&lt;/code&gt;: This folder contains your app’s NativeScript modules, which are a series of NativeScript-provided JavaScript modules you’ll use to build your app. Each module contains the platform-specific code needed to implement some feature—the camera, http calls, the file system, and so forth—exposed through a platform-agnostic API (e.g. camera.takePicture()). We’ll look at some examples momentarily.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;package.json&lt;/code&gt;: This file contains your app’s configuration details, such as your app id, the version of NativeScript you’re using, and also which npm modules your app uses. We’ll take a closer look at how to use this file when we talk about using npm modules in chapter 5.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;platform&lt;/code&gt;s: This folder contains the platform-specific code NativeScript needs to build native iOS and Android apps. For example in the android folder you’ll find things like your project’s AndroidManifest.xml and .apk executable files. Similarly, the ios folder contains the Groceries’ Xcode project and .ipa executables. Note, users on Windows machines will not have an ios folder.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Application code is written using JavaScript and the user interface designed using XML. Inside the &lt;code class=&quot;highlighter-rouge&quot;&gt;app&lt;/code&gt; folder is a file called &lt;code class=&quot;highlighter-rouge&quot;&gt;main-page.xml&lt;/code&gt; which has the default user interface code. In &lt;code class=&quot;highlighter-rouge&quot;&gt;main-view-model.js&lt;/code&gt; is the default model code and&lt;code class=&quot;highlighter-rouge&quot;&gt; main-page.js&lt;/code&gt; defines the application logic. Finally &lt;code class=&quot;highlighter-rouge&quot;&gt;app.js&lt;/code&gt; contains the code to start the application with the defined modules.&lt;/p&gt;

&lt;h2 id=&quot;designing-the-app&quot;&gt;Designing the app&lt;/h2&gt;

&lt;p&gt;Let’s start by designing the application using XML. Open &lt;code class=&quot;highlighter-rouge&quot;&gt;main-page.xml&lt;/code&gt; and look at the default code. Remove everything except the &lt;code class=&quot;highlighter-rouge&quot;&gt;Page&lt;/code&gt; tag. The &lt;code class=&quot;highlighter-rouge&quot;&gt;Page&lt;/code&gt; tag has an attribute called &lt;code class=&quot;highlighter-rouge&quot;&gt;loaded&lt;/code&gt; which executes the &lt;code class=&quot;highlighter-rouge&quot;&gt;pageLoaded&lt;/code&gt; function once the app loads. The &lt;code class=&quot;highlighter-rouge&quot;&gt;pageLoaded&lt;/code&gt; function is inside the &lt;code class=&quot;highlighter-rouge&quot;&gt;main-page.js&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;This project will use a &lt;em&gt;stack layout&lt;/em&gt; to design our app. There are &lt;a href=&quot;http://docs.nativescript.org/layouts&quot;&gt;a number of layouts offered by native script&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Inside the Page tag add the stack layout.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &amp;lt;StackLayout orientation=&quot;vertical&quot;&amp;gt;
    &amp;lt;/StackLayout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Define the stack layout with a vertical orientation. Add a button inside the stack layout.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &amp;lt;Button text=&quot;Get beer list&quot; height=&quot;50px&quot; style=&quot;width:300px;border:none;font-size:20px;&quot; /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Save changes and run the app. It should look something like the below.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2015-12-01-get_beer_list_btn.png&quot; alt=&quot;After adding button&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;fetching-data-from-beer-catalog&quot;&gt;Fetching data from Beer catalog&lt;/h2&gt;

&lt;p&gt;Add an attribute called &lt;code class=&quot;highlighter-rouge&quot;&gt;tap&lt;/code&gt; to the &lt;em&gt;Get beer list&lt;/em&gt; button.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    tap=&quot;beers&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Now, when the user taps the search button the &lt;code class=&quot;highlighter-rouge&quot;&gt;beers&lt;/code&gt; function is called.
Let’s define the &lt;code class=&quot;highlighter-rouge&quot;&gt;beers&lt;/code&gt; function inside&lt;code class=&quot;highlighter-rouge&quot;&gt; main-page.js&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    exports.beers = function() {
      // Code would be here !
    };
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Calling the API will require the &lt;code class=&quot;highlighter-rouge&quot;&gt;http&lt;/code&gt; module, so import the module into &lt;code class=&quot;highlighter-rouge&quot;&gt;main-page.js&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    var http = require(&quot;http&quot;);
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Inside the &lt;code class=&quot;highlighter-rouge&quot;&gt;beers&lt;/code&gt; function, and using the &lt;code class=&quot;highlighter-rouge&quot;&gt;http&lt;/code&gt; module, now make the API call.
For the needs of this tutorial, the beer catalog is a JSON file on
&lt;code class=&quot;highlighter-rouge&quot;&gt;http://www.beer-tutorials.org/beers/beers.json&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    http.getJSON(&quot;http://www.beer-tutorials.org/beers/beers.json&quot;).then(function(r) {

        console.log(JSON.stringify(r));

    }, function(e) {

        console.log(e);

    });
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The code above makes the API call.&lt;/p&gt;

&lt;p&gt;When running an app in the emulator you will need to run ‘adb logcat’ to check log messages.&lt;/p&gt;

&lt;p&gt;Save changes and run the app on the emulator. Click the &lt;em&gt;get beer list&lt;/em&gt; button and the
returned result from the server should be visible in terminal.&lt;/p&gt;

&lt;p&gt;Next use the response returned to push the beers information to an array.&lt;/p&gt;

&lt;p&gt;An &lt;code class=&quot;highlighter-rouge&quot;&gt;observable array&lt;/code&gt; is required to create and detect changes to a collection of things.
Bind this same observable array to the view so that the view updates whenever a change occurs.&lt;/p&gt;

&lt;p&gt;To create the &lt;code class=&quot;highlighter-rouge&quot;&gt;observable array&lt;/code&gt;, add these variable declarations to &lt;code class=&quot;highlighter-rouge&quot;&gt;main-page.js&lt;/code&gt; :&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    var observableArray = require(&quot;data/observable-array&quot;);
    var beerList = new observableArray.ObservableArray([]);
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Then, inside of the http.getJSON().then() method,  iterate through the returned data. Push each beer object into the beerList observableArray:&lt;/p&gt;

&lt;p&gt;function beers(args) {
    http.getJSON(“http://www.beer-tutorials.org/beers/beers.json”).then(function (r) {
        for (var i = 0; i&amp;lt; r.length; i++) {
            var beer = {
                name: r[i].name,
                description: r[i].description,
                alcohol: r[i].alcohol
            }
            beerList.push(beer);
        }
    },
        function (e) {
            console.log(e);
        }
    );
}&lt;/p&gt;

&lt;h2 id=&quot;binding-data-to-the-ui&quot;&gt;Binding data to the UI&lt;/h2&gt;

&lt;p&gt;Once the data is in the &lt;code class=&quot;highlighter-rouge&quot;&gt;beersList&lt;/code&gt; array, bind it to the UI. For displaying the data, create a &lt;code class=&quot;highlighter-rouge&quot;&gt;ListView&lt;/code&gt; in &lt;code class=&quot;highlighter-rouge&quot;&gt;main-page.xml&lt;/code&gt;, underneath the existing &lt;code class=&quot;highlighter-rouge&quot;&gt;Button&lt;/code&gt; element.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &amp;lt;ListView&amp;gt;
        &amp;lt;ListView.itemTemplate&amp;gt;
          &amp;lt;StackLayout orientation=&quot;vertical&quot;&amp;gt;
            &amp;lt;Label id=&quot;name&quot; class=&quot;beerName&quot; /&amp;gt;
            &amp;lt;Label id=&quot;description&quot; textWrap=&quot;true&quot; /&amp;gt;
          &amp;lt;/StackLayout&amp;gt;
        &amp;lt;/ListView.itemTemplate&amp;gt;
    &amp;lt;/ListView&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Bind the &lt;code class=&quot;highlighter-rouge&quot;&gt;beersList&lt;/code&gt; array to the list view:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &amp;lt;ListView items=&quot;{{ beerList }}&quot;&amp;gt;
    &amp;lt;ListView.itemTemplate&amp;gt;
      &amp;lt;StackLayout orientation=&quot;vertical&quot;&amp;gt;
        &amp;lt;Label id=&quot;name&quot; text=&quot;{{name}}&quot; class=&quot;beerName&quot; /&amp;gt;
        &amp;lt;Label id=&quot;description&quot; text=&quot;{{ description }}&quot; textWrap=&quot;true&quot; /&amp;gt;
      &amp;lt;/StackLayout&amp;gt;
    &amp;lt;/ListView.itemTemplate&amp;gt;
    &amp;lt;/ListView&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;To make our list more user friendly, we also add some CSS to &lt;code class=&quot;highlighter-rouge&quot;&gt;app.css&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    .beerName {
      font-size: 20;
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;For the &lt;code class=&quot;highlighter-rouge&quot;&gt;beersList&lt;/code&gt; array to be available across the view, set the &lt;code class=&quot;highlighter-rouge&quot;&gt;beersList&lt;/code&gt; array in the observable module. Do this by importing an observable module and using it to create an observable object.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    var observableModule = require(&quot;data/observable&quot;);
    var pageData = new observableModule.Observable();
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;In the &lt;code class=&quot;highlighter-rouge&quot;&gt;pageLoaded&lt;/code&gt; function, set the images array to the observable module and add the observable module to the page context.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    function pageLoaded(args) {
        var page = args.object;
        pageData.set(&quot;beerList&quot;, beerList);
        // it links an xml &quot;beerList&quot; variable to a js beerList variable
        page.bindingContext = pageData;
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;h2 id=&quot;getting-the-beers-pics&quot;&gt;Getting the beers pics&lt;/h2&gt;

&lt;p&gt;We can also extract the image URL from the received JSON :&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    var beer = {
      name: r[i].name,
      description: r[i].description,
      alcohol: r[i].alcohol,
      img: &quot;http://beertutorials.github.io/website/&quot;+r[i].img
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;And then we add the image to the &lt;code class=&quot;highlighter-rouge&quot;&gt;ListView.itemTemplate&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &amp;lt;ListView.itemTemplate&amp;gt;
      &amp;lt;StackLayout orientation=&quot;horizontal&quot;&amp;gt;
        &amp;lt;Image width=&quot;100px&quot; height=&quot;100px&quot; src=&quot;&quot; /&amp;gt;
        &amp;lt;StackLayout orientation=&quot;vertical&quot;&amp;gt;
          &amp;lt;Label id=&quot;name&quot; text=&quot;&quot; class=&quot;beerName&quot; /&amp;gt;
          &amp;lt;Label id=&quot;description&quot; text=&quot;&quot; textWrap=&quot;true&quot; /&amp;gt;
        &amp;lt;/StackLayout&amp;gt;
      &amp;lt;/StackLayout&amp;gt;
    &amp;lt;/ListView.itemTemplate&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/img/2015-12-01-beers-with-pics.png&quot; alt=&quot;After adding pics&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;lets-forget-the-button&quot;&gt;Let’s forget the Button&lt;/h2&gt;

&lt;p&gt;Let’s call for the beer list without button. We are going to use application’s lifecycle method &lt;code class=&quot;highlighter-rouge&quot;&gt;onLaunch&lt;/code&gt;
on &lt;code class=&quot;highlighter-rouge&quot;&gt;app.js&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;application.on(application.launchEvent, function (args) {
   var mainPage = require(&quot;./main-page&quot;);
   mainPage.beers();
})

application.start();
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;application.start()&lt;/code&gt; must be the &lt;strong&gt;last&lt;/strong&gt; instruction of the &lt;code class=&quot;highlighter-rouge&quot;&gt;app.js&lt;/code&gt; file, any instruction after it would be ignored in some platforms.&lt;/p&gt;

&lt;p&gt;Now you can delete the &lt;code class=&quot;highlighter-rouge&quot;&gt;Buttom&lt;/code&gt; from &lt;code class=&quot;highlighter-rouge&quot;&gt;main-page.xml&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;and-how-about-the-actionbar-title&quot;&gt;And how about the ActionBar title?&lt;/h2&gt;

&lt;p&gt;To have access to the &lt;code class=&quot;highlighter-rouge&quot;&gt;ActionBar&lt;/code&gt; with the application title, you only need to explicitly declare it in &lt;code class=&quot;highlighter-rouge&quot;&gt;main-page.xml&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;Page xmlns=&quot;http://schemas.nativescript.org/tns.xsd&quot; loaded=&quot;pageLoaded&quot;&amp;gt;
  &amp;lt;Page.actionBar&amp;gt;
    &amp;lt;ActionBar title=&quot;NativeScript Beers&quot; android.icon=&quot;res://ic_test&quot;/&amp;gt;
  &amp;lt;/Page.actionBar&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/img/2015-12-01-beers-with-pics-no-button.png&quot; alt=&quot;After adding pics&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Tue, 01 Dec 2015 00:00:00 +0000</pubDate>
        <link>http://www.beer-tutorials.orghttp://www.beer-tutorials.org/2015/12/01/NativeScript-Beers/</link>
        <guid isPermaLink="true">http://www.beer-tutorials.orghttp://www.beer-tutorials.org/2015/12/01/NativeScript-Beers/</guid>
        
        
      </item>
    
  </channel>
</rss>
