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
Do you have any medicine? Capsules, fish oil, mel...
The launch of mini programs has brought convenien...
When promoting products, app planners and promote...
Humans have conducted many explorations on the mo...
One minute with the doctor, the postures are cons...
Elderly people's addiction to mobile phones, ...
1.The darker the egg yolk, the more nutritious it...
"Three months ago, I was an official, and no...
【51CTO.com Quick Translation】Just a few years ago...
What’s wrong with Meituan monthly payment not bei...
For some people who drive, there are two major tro...
Xiaohongshu is known as a popular shopping tool f...
The news of PS VR landing in China has become a h...
In recent days, a marketing director left a messa...
A transaction worth 2.18 billion yuan brought LeT...