{"id":274,"date":"2017-10-14T13:06:01","date_gmt":"2017-10-14T07:36:01","guid":{"rendered":"http:\/\/blog.openwebsolutions.in\/?p=274"},"modified":"2017-10-22T12:13:21","modified_gmt":"2017-10-22T06:43:21","slug":"create-reaction-emoji-using-ionic-framework","status":"publish","type":"post","link":"https:\/\/openwebsolutions.in\/blog\/create-reaction-emoji-using-ionic-framework\/","title":{"rendered":"How to create reaction emoji using Ionic Framework"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>In this blog I am going to show how to create simple reaction emojis in an Ionic app. Please note: I am using free images from google. Let us move on to our first step.<\/p>\n<h4>Step 1 :<\/h4>\n<p>Install Node JS first. You can download node js from <a href=\"https:\/\/nodejs.org\/en\/download\/\"><em>https:\/\/nodejs.org\/en\/download\/<\/em><\/a><\/p>\n<p>Install Ionic from <a href=\"https:\/\/ionicframework.com\/getting-started\/\"><em>https:\/\/ionicframework.com\/getting-started\/<\/em><\/a><\/p>\n<p>If you have already downloaded those skip this step.<\/p>\n<p>&nbsp;<\/p>\n<h4>Step 2 :<\/h4>\n<p>Create a blank ionic app<\/p>\n<p>Open command prompt if you are using windows or open terminal if you are using Linux \/ Mac and then type the following code (here my app name is myEmojiApp)<\/p>\n<p><em>ionic start myEmojiApp blank<\/em><\/p>\n<p><em>cd myEmojiApp<\/em><\/p>\n<p><em>ionic serve<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>Step 3 :<\/h4>\n<p><em>home.html<\/em><\/p>\n<p>Go to <em><a href=\"https:\/\/ionicframework.com\/docs\/components\/#fabs\">https:\/\/ionicframework.com\/docs\/components\/#fabs<\/a><\/em> and use Floating action buttons for various types of emoji<\/p>\n<p>I am going to put those codes into the home.html.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-275\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/10\/step1.png\" alt=\"step2\" width=\"655\" height=\"168\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step1.png 717w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step1-300x77.png 300w\" sizes=\"(max-width: 655px) 100vw, 655px\" \/><\/p>\n<p>Here we are using 4 types of expression. Like,\u00a0 Love, Dislike and Angry<\/p>\n<p>&nbsp;<\/p>\n<h4>Step 4 :<\/h4>\n<p>In the assets folder create a folder named Images and put all the images that we are going to show on click of each expressions<\/p>\n<p>In my case I am using 4 types of images for 4 types of emoji<\/p>\n<p><em>angry.png<\/em><\/p>\n<p><em>dislike.jpg<\/em><\/p>\n<p><em>heart.png<\/em><\/p>\n<p><em>like.jpg<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>Step 5 :<\/h4>\n<p><em>Home.html<\/em><\/p>\n<p>We will trigger a function called addExpression() on click each emoji buttons<\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-276\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/10\/step4.png\" alt=\"Step 5\" width=\"623\" height=\"284\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step4.png 760w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step4-300x137.png 300w\" sizes=\"(max-width: 623px) 100vw, 623px\" \/><\/p>\n<p>Let us provide template id (i.e. \u00a0#demo) and element id (i.e. \u00a0id=\u201ddemo\u201d) in the each emoji buttons<\/p>\n<p>And we will pass the id as a parameter or argument within that above declared function.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-290\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/10\/step4-1.png\" alt=\"Step 5-b\" width=\"776\" height=\"348\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step4-1.png 776w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step4-1-300x135.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step4-1-768x344.png 768w\" sizes=\"(max-width: 776px) 100vw, 776px\" \/><\/p>\n<h4><\/h4>\n<p>&nbsp;<\/p>\n<h4>Step 6 :<\/h4>\n<p><em>home.ts<\/em><\/p>\n<p>Here we will define our function addExpression()<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-277\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/10\/step5.png\" alt=\"Step 6\" width=\"750\" height=\"424\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step5.png 750w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step5-300x170.png 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/p>\n<p>Here we will have a string type variable \u201c<em>expression<\/em>\u201d<\/p>\n<p>Within that function we are assigning the variable with the element id which we are getting from that argument \u201c<em>val<\/em>\u201d (i.e. like, love etc.)<\/p>\n<p>If we open the browser console and click those emoji buttons we can see the expression id for each click in that console.<\/p>\n<p>&nbsp;<\/p>\n<h4>Step 7 :<\/h4>\n<p><em>Home.html<\/em><\/p>\n<p>We will add a simple div container below &lt;ion-fab&gt;&lt;\/ion-fab&gt; to show the exact images for each emoji<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-278\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/10\/step6.png\" alt=\"Step 7\" width=\"621\" height=\"70\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step6.png 621w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step6-300x34.png 300w\" sizes=\"(max-width: 621px) 100vw, 621px\" \/><\/p>\n<p>Within the div container we will use <em>img<\/em> tag to show the images. <strong>The main logic will be here.<\/strong><\/p>\n<p>We are going to use <strong>ternary nested if condition<\/strong> here. Thus you will also know how to use ternary nested if conditions in Ionic app.<\/p>\n<p><em>&lt;img src=&#8221;assets\/images&#8221; alt=&#8221;&#8221;&gt;<\/em><\/p>\n<p>If we print expression variable value here we have to write {{expression}} for Ionic<\/p>\n<p>Thus we can use this variable as alternative text of img tag like<\/p>\n<p><em>&lt;img src=&#8221;assets\/images&#8221; alt=&#8221;{{expression}}&#8221;&gt;<\/em><\/p>\n<blockquote><p>Now as per ternary condition we can write the logic like \u201c<em>if expression value is equal to like then use image like.jpg else blank<\/em>\u201c<\/p><\/blockquote>\n<p>So, we can write in ternary operator <em>{{expression==\u2019like\u2019?\u2019like.jpg\u2019:\u2019\u2019}}<\/em><\/p>\n<blockquote><p>And if we want that \u201c<em>if expression value is equal to like then use image like.jpg else if expression value is equal to love then use image heart.png else if expression value is dislike then use image dislike.jpg and lastly if expression value is angry then use image angry.png<\/em>\u201d<\/p><\/blockquote>\n<p>In this case we have to write <em>{{expression == &#8216;like&#8217;?&#8217;like.jpg&#8217;:expression == &#8216;love&#8217;?&#8217;heart.png&#8217;:expression == &#8216;dislike&#8217;?&#8217;dislike.jpg&#8217;:expression == &#8216;angry&#8217;?&#8217;angry.png&#8217;:&#8221;}}<\/em><\/p>\n<p>Now it is clear how to use ternary nested if else conditions in one single line<\/p>\n<p>We can write the following now<\/p>\n<p><em>&lt;img src=&#8221;assets\/images\/{{expression == &#8216;like&#8217;?&#8217;like.jpg&#8217;:expression == &#8216;love&#8217;?&#8217;heart.png&#8217;:expression == &#8216;dislike&#8217;?&#8217;dislike.jpg&#8217;:expression == &#8216;angry&#8217;?&#8217;angry.png&#8217;:&#8221;}}&#8221; alt=&#8221;{{expression}}&#8221;&gt;<\/em><\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-279\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/10\/step6-2.png\" alt=\"Step 7-b\" width=\"631\" height=\"85\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step6-2.png 832w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step6-2-300x40.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step6-2-768x103.png 768w\" sizes=\"(max-width: 631px) 100vw, 631px\" \/><\/p>\n<p>We can declare the values as class here<\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-280\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/10\/step6-3.png\" alt=\"Step 7-c\" width=\"624\" height=\"93\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step6-3.png 837w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step6-3-300x45.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step6-3-768x115.png 768w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h4>Step 8 :<\/h4>\n<p><em>home.scss<\/em><\/p>\n<p>We can style the image container div as per our need.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone wp-image-281\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/10\/step7.png\" alt=\"Step 8\" width=\"626\" height=\"127\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step7.png 634w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/step7-300x61.png 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h4>Step 9 :<\/h4>\n<p>That\u2019s it . Now if we run the app on <strong><em>localhost:8100<\/em><\/strong> it will look like<\/p>\n<p><img loading=\"lazy\" class=\"size-full wp-image-282 aligncenter\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/10\/demo.png\" alt=\"Demo\" width=\"249\" height=\"437\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/demo.png 249w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/demo-171x300.png 171w\" sizes=\"(max-width: 249px) 100vw, 249px\" \/><\/p>\n<p>You can view or download the full code from <a href=\"https:\/\/github.com\/PreetamMallick\/buttons-of-expression-using-ionic-framework-for-native-app\"><em><strong>Github<\/strong><\/em><\/a><\/p>\n<p>Please share if you like it!<\/p>\n<p>Follow me on <a href=\"https:\/\/www.linkedin.com\/in\/preetam-mallick-84321254\/\"><em><strong>LinkedIn<\/strong><\/em><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; In this blog I am going to show how to create simple reaction emojis in an Ionic app. Please note: I am using free images from google. Let us move on to our first step. Step 1 : Install Node JS first. You can download node js from https:\/\/nodejs.org\/en\/download\/ Install Ionic from https:\/\/ionicframework.com\/getting-started\/ If [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":283,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12,3,18,5],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create reaction emoji using Ionic Framework - Openweb Solutions Blog<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/openwebsolutions.in\/blog\/create-reaction-emoji-using-ionic-framework\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create reaction emoji using Ionic Framework - Openweb Solutions Blog\" \/>\n<meta property=\"og:description\" content=\"&nbsp; In this blog I am going to show how to create simple reaction emojis in an Ionic app. Please note: I am using free images from google. Let us move on to our first step. Step 1 : Install Node JS first. You can download node js from https:\/\/nodejs.org\/en\/download\/ Install Ionic from https:\/\/ionicframework.com\/getting-started\/ If [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/openwebsolutions.in\/blog\/create-reaction-emoji-using-ionic-framework\/\" \/>\n<meta property=\"og:site_name\" content=\"Openweb Solutions Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-10-14T07:36:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-10-22T06:43:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/emoji-banner.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"497\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/\",\"name\":\"Openweb Solutions Blog\",\"description\":\"Transforming ideas into reality\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/openwebsolutions.in\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/create-reaction-emoji-using-ionic-framework\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/10\/emoji-banner.jpg\",\"width\":1024,\"height\":497,\"caption\":\"Ionic emoji app banner\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/create-reaction-emoji-using-ionic-framework\/#webpage\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/create-reaction-emoji-using-ionic-framework\/\",\"name\":\"How to create reaction emoji using Ionic Framework - Openweb Solutions Blog\",\"isPartOf\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/create-reaction-emoji-using-ionic-framework\/#primaryimage\"},\"datePublished\":\"2017-10-14T07:36:01+00:00\",\"dateModified\":\"2017-10-22T06:43:21+00:00\",\"author\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/615090f954d8460cf6186cf920b47398\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/openwebsolutions.in\/blog\/create-reaction-emoji-using-ionic-framework\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/615090f954d8460cf6186cf920b47398\",\"name\":\"Preetam Mallick\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ed836329485e177373e4ff5323b6670a?s=96&r=g\",\"caption\":\"Preetam Mallick\"},\"description\":\"Frontend developer at Openweb Solutions\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/274"}],"collection":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=274"}],"version-history":[{"count":12,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/274\/revisions"}],"predecessor-version":[{"id":311,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/274\/revisions\/311"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media\/283"}],"wp:attachment":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}