introduce Since hybrid mobile development became popular, some web engineers have begun to switch to mobile development. Hybrid mobile development technology allows web engineers to develop mobile applications for various platforms without having to learn the native programming languages of each platform. There are already many hybrid development platforms such as PhoneGap and Titanium to help us with hybrid programming. Today we are going to introduce a newer hybrid mobile development platform, Ionic. Ionic is an advanced HTML5 hybrid mobile application development framework and an open source front-end framework. Ionic applications are based on Cordova, so Cordova-related tools can also be built into the application. Ionic focuses on visual effects and user experience, so AngularJS is used to build a variety of cool effects. Install To get started with Ionic development, you need to install Node.js. Then install the corresponding Android or IOS platform according to your development environment. In this article, we will create an Android application. Next you need to install a Cordova and Ionic command line tool, as follows:
After the installation is complete, you can try to start creating a project:
Enter the project directory, add the ionic platform, create an application, run it in a virtual machine, and become tall, rich and handsome...
Here is the sample application effect: start We've got a good start, now let's create a ToDo list app. We start with the blank template:
If you go into the project directory, you will see the AngularJS file, this is where we will add the relevant code. Creating and displaying listsFirst, you need to add a list to your application. We will use ion-list directly. Add ion-list to www/index.html:
Then let's take a look at what our HTML file looks like after adding ion-list:
Then we can create a controllers.js file in www/js/ to define a new cntroller, we will call it ToDoListCtrl for now. Here is the content of the controllers.js file:
In the above code, we defined a module called starter and a Controller called ToDoListCtrl. Then we need to add this module to our application. Open www/js/app.js and add the module:
Let's go ahead and define a $scope to carry the items in the ToDo list. Declare a new $scope variable in ToDoListCtrl as follows:
Add controllers.js to index.html:
In the code above, we added bar-positive to add color to the application. You can add many different headers in the same way. There is detailed documentation here: here. We now need to add a button in index.html to trigger the event:
Now let's confirm that in the above operation, we added a header, an input box and a button to the modal. We also need a back button in the header, which is used to trigger the closeModal() function. Now we start binding ionic modal to our controller. We inject $ionicModal into the controller as follows:
In the above code, we use .fromTemlateUrl to load the HTML content, and then define the $scope and animation types through two options during initialization. Of course we also define methods to open and close the moda and add items to the array. run Okay, everything is ready, let’s start the virtual machine. It looks good, right? Summarize In this article, we have seen a rough process of using Ionic. You can see the detailed code here. If you want to learn more, you should learn more about AngularJS. Reference: If you are interested, you can read this basic AngularJS development tutorial: Introduction to Practical Programming of AngularJS Development Framework Part 1 via sitepoint |
<<: Chinese Internet companies may join forces to give Apple an embarrassing problem
>>: Apple is rumored to be planning a new 4-inch iPhone in 2015
Promotion is in the third position on the left. T...
LeTV TV, which has always been a disruptor with i...
Every autumn and winter, you can always see a gia...
After I used text messages to activate lost custo...
As time goes by, the Kuaishou market is constantl...
In the Middle East There is such a country In the...
As 2016 draws to a close, mobile videos represent...
In the Internet industry, users who start using a...
In the past six months, especially during the epi...
Today, you can buy train tickets for the last day ...
In our zoo, every time autumn comes, we have a su...
This is a relatively hardcore article. In additio...
Now we often hear that taking children to outdoor...
The summit forum held one day before ChinaJoy (Ch...