Hybrid apps are changing the way people build mobile applications. With Ionic 2, hybrid app developers are gifted with not only a fresh, well-built, and powerful platform, but also a tool to enjoy their development experience. Apps can be built in record time, yet remain visually attractive and contain advanced features.
Introducing Ionic 2, will help you discover all the building blocks of an Ionic 2 application. You will learn how to use built-in components, make API calls, and style your app to your liking, so prepare yourself for many hours of fun development with Ionic 2.
We’ll start by bootstrapping an application, enhancing one cool feature at a time. Each feature will cover one of the essential components of an app: user experience, logic and data, and the user interface. By the end of the course, we will have built an entire awesome iTunes Browser app.
First, you’ll find out how to add pages and navigate between them, including going back and forth. Once new pages are in place, we’ll focus on grabbing real data from an API via AJAX with and without JSONP. With data and views in place, we’ll focus on improving the user experience and using modals, action sheet, alerts, loaders, and even a fully validated form. We also cover a range of various topics including styling, navigation with parameters, and Angular 2 pipes to filter and transform the way data is presented.
Introducing Ionic 2 will take you on the same journey as if you were building a real application, from scratch to a working product. You’ll soon see how this powerful mobile application framework can make your development fast, structured, and at the same time incredibly enjoyable.
About The Author
Mathieu Chauvinc is a Managing Director at Red Ape Solutions and works on keeping the company at the bleeding edge of web technologies. On a daily basis, he leads the tech team of 15 and collaborates with them in building complex single page applications and neat hybrid mobile apps. He has been involved in web technologies for over a decade, from Django to Go, SQL to NoSQL, Mootools to Angular, continuously trying to keep the right balance between the excitement of new frameworks and the stability of proven ones. He always has a special place in his heart for Python and Django.
Starting a project can sometimes mean installing tons of things and can be quite a lengthy process before everything is up and running. However, this is not the case with Ionic 2, which offers a great CLI and a "start" command to bootstrap code, including a side menu, several pages, and so on.
It is important for developers to be familiar and comfortable with the structure of the project. We'll take a look at the location of some of the different elements of the project, configurations, dependencies, hooks, and actual app components.
The app needs to be served, but this depends on its status. Let's take a look at which way of serving is better. The live reload server is an obvious winner for ease of use and debugging, while the new lab view helps us think about the experience on both Android and iOS. Emulators give a better idea as to the real experience that users will have; finally, the device can be used when the app is close to finalized.
Apps always contain several pages. We need to create them and ensure that they are navigable.
Ionic2's navigation system is very different from the previous version. We will take a look at how the stack is used and the difference between the root and the other pages.
Navigation concepts are acquired; it is time to apply them to our application.
We need to present the list of search results in a visually attractive list. Ionic makes this easy with the ion-list and ion-icon components, and Angular allows us to repeat the items using ngFor as well as bind the values of attributes to the DOM elements' properties.
The app executes a search on the iTunes API. This requires a search bar that will react when the user presses "enter". We'll use the search bar component to present the query input and bind to the keyup as well as cancel events.
The search should be targeted to a specific country's iTunes API. So, we will create a settings page in which we'll use a radio to select the country.
We need to load real data from an API. For this, we need HTTP_PROVIDERS to be provided and the HTTP service to be dependency injected.
Some APIs do not allow cross-origin calls. Also, having logic coded inside the component itself isn't a good practice. So, we'll create our own service and make use of Jsonp to get around the cross-origin restrictions
Filtering and other calls for actions are vital in any app but not easy to present smartly in a mobile application. Action sheet is a great solution to this issue; it displays a nice overlay, and we can code what happens when we click on each button.
Temporary or intermediary pages are often necessary in applications. Although we know we can navigate to a page with a Back button, a modal makes more sense sometimes from a user-experience perspective. We will create such a modal and pass the track we clicked on as part of the navigation to display a preview of this track.
Cell phones often face a shortage of space. So relying on a bulky button is rather outdated. Pull-to-refresh is an amazing user experience tool that allows you to pull a list of items and refresh it with new ones.
The application needs to communicate with the user. Through the use of various dialogs, an alert, a confirm box, and a prompt, we will make the app clearer and more interactive with the user.
Tasks run in the background can be confusing to the user; they can't see that something is happening. Loaders or progress indicators take care of this issue and give users a clear statement that their request is being processed.
Forms are one of the most common type of interaction with users. They can be tedious to build and validate, though. We will use the FormBuilder service to create a form focused on its inputs and leverage the validation framework to display error messages when needed.
Though the app looks really nice, it is rare that your corporate colors match the out-of-the-box Ionic feel. Ionic uses a large number of SASS variables, which you can override in order to make the app feel more like your own.
We need to be able to navigate to the artist view and to pass along the artist we are looking at. Extra information can be passed during navigation to either root pages or intermediary pages. On the destination page, NavParams can be used to retrieve said information.
Carousels or sliders are a very common type of display for limited lists where visuals are important. The built-in ion-slides allow us to very quickly come up with such a carousel and takes care of touch events, such as sliding.
It is sometimes troublesome and also less declarative to work on data only within the controller. Pipes allow us to modify data from within the template. They are typically used to filter arrays or format content (dates, pluralization, and currency)
Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.
With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.
From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.
Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.