{"id":1531,"date":"2022-01-12T14:10:48","date_gmt":"2022-01-12T13:10:48","guid":{"rendered":"https:\/\/nguenkam.com\/blog\/?p=1531"},"modified":"2022-01-12T14:12:38","modified_gmt":"2022-01-12T13:12:38","slug":"converting-angular-web-application-into-ionic-app","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2022\/01\/12\/converting-angular-web-application-into-ionic-app\/","title":{"rendered":"Converting Angular Web Application into Ionic App"},"content":{"rendered":"\n<p>In the software industry, after you successfully built a web application aligned with the client requirements, you may be asked to build a mobile application for the same web application to address mobile users&#8217; requirements. Therefore this article will provide you with better guidance to convert an existing web application developed using Angular into an Ionic native app by simple and detailed instructions.<\/p>\n\n\n\n<p><em><strong>Angular<\/strong> is a famous front-end web development framework which is Typescript-based and open source. Angular Components are used to modify our program HTML, CSS, and logic.<\/em><\/p>\n\n\n\n<p><em><strong>Ionic<\/strong> is a mobile application development framework which is an open-source SDK and guides to build HTML5 mobile applications. Ionic can handle mobile UIs in an efficient manner by bringing mobile app feeling to the user.<\/em><\/p>\n\n\n\n<p>Let\u00b4s create a new angular project nammed \u201cangular-ionic\u201d , and then &nbsp;navigate to that newly created directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ng new angular-ionic\ncd angular-ionic<\/code><\/pre>\n\n\n\n<p>Our purpose is to create a mobile app for the same web application, therefore it is needed to add Ionic to the existing project. To do that you can use the Angular CLI command <em><strong>\u201cng add\u201d<\/strong><\/em> to import Ionic packages to the existing project. The following command will help you to do that.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ng add @ionic\/angular<\/code><\/pre>\n\n\n\n<p>After successful package installation, you will take the output as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"871\" height=\"237\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-2.png\" alt=\"\" class=\"wp-image-1532\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-2.png 871w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-2-300x82.png 300w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-2-768x209.png 768w\" sizes=\"(max-width: 871px) 100vw, 871px\" \/><\/figure>\n\n\n\n<p>Then you must initialize your existing project with Ionic by using the following command.&nbsp;<strong>If you use this command you will ask a question to enter your project name. <span class=\"has-inline-color has-vivid-red-color\">Make sure to enter the project name as your existing project name<\/span>. In this case project name is angular-ionic.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ionic init<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"880\" height=\"93\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-3.png\" alt=\"\" class=\"wp-image-1533\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-3.png 880w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-3-300x32.png 300w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-3-768x81.png 768w\" sizes=\"(max-width: 880px) 100vw, 880px\" \/><\/figure>\n\n\n\n<p>After successful initialization of Ionic to the project, you should be done below 2 changes to the angular.json file which provides details about project-specific configurations.<\/p>\n\n\n\n<ol><li>Change outputPath \u201cdist\/angular-ionic\u201d to&nbsp;<strong>\u201cwww\u201d&nbsp;<\/strong>in the angular.json file to set folders to build Ionic project for www.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"862\" height=\"790\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-4.png\" alt=\"\" class=\"wp-image-1534\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-4.png 862w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-4-300x275.png 300w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-4-768x704.png 768w\" sizes=\"(max-width: 862px) 100vw, 862px\" \/><\/figure>\n\n\n\n<p>2. Change &lt;base href=\u201d\/\u201d&gt; into&nbsp;<strong>&lt;base href=\u201d.\/\u201d&gt;<\/strong>&nbsp;in the index.html file. &lt;base href=\u201d\u201d&gt; defines the base URL for all the relative URL is the document and by&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/stackoverflow.com\/questions\/48555550\/what-does-href-means-in-angular-2-4\" target=\"_blank\">default, it is set to root.<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"862\" height=\"532\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-5.png\" alt=\"\" class=\"wp-image-1535\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-5.png 862w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-5-300x185.png 300w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/01\/image-5-768x474.png 768w\" sizes=\"(max-width: 862px) 100vw, 862px\" \/><\/figure>\n\n\n\n<p>After doing the above changes you can create an Android APK for your project and use the following command to do so.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ionic cordova run android --project=\"angular-ionic\"<\/code><\/pre>\n\n\n\n<p>Great\u2026 You will end up with a mobile application that has been built upon your web application.<\/p>\n\n\n\n<p>Your built Android APK can be found under the platform&#8217;s root folder and move with \u201cplatforms\\android\\app\\build\\outputs\\apk\\debug\u201d. You can install it via mobile phone or by enabling the emulator you can see your Ionic mobile app!!!<\/p>\n\n\n\n<p>It is important to notice that, you may have to fix mobile responsiveness issues of your native app like alignment issues, the appearance of icons and images, spacing issues, etc.<\/p>\n\n\n\n<p><strong><em>PS: <\/em><\/strong><em>Here you can see that with use of&nbsp;<\/em><a rel=\"noreferrer noopener\" href=\"https:\/\/cordova.apache.org\/docs\/en\/10.x\/guide\/overview\/index.html\" target=\"_blank\">cordova<\/a><em>&nbsp;we could render our web application into a native web view. Cordova is an open source framework which can be used to implement native application for various mobile platforms by using&nbsp;<\/em><a rel=\"noreferrer noopener\" href=\"https:\/\/ionic.io\/resources\/articles\/what-is-apache-cordova\" target=\"_blank\">HTML, CSS, and JavaScript contents<\/a><em>.<\/em><\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h5>Reference:<\/h5>\n\n\n\n<p><a href=\"https:\/\/levelup.gitconnected.com\/\">https:\/\/levelup.gitconnected.com\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the software industry, after you successfully built a web application aligned with the client requirements, you may be asked to build a mobile application for the same web application to address mobile users&#8217; requirements. Therefore this article will provide you with better guidance to convert an existing web application developed using Angular into an [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1536,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[37,434],"tags":[141,431,429,430,432,433],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1531"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1531"}],"version-history":[{"count":2,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1531\/revisions"}],"predecessor-version":[{"id":1538,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1531\/revisions\/1538"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/1536"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}