Phonegap+cordova+ionic calling native API

Source: Internet
Author: User
Tags jquery library

On a blog about Phonegap+cordova+ionic environment, today to share a Cordova call native API article. Technically speaking, this is not very difficult, but some details without notice, or some of the steps do not know, then in the pit 1:30 will be difficult to climb out. So these two blogs are designed to help small partners save more time to do other meaningful things.

1. New Project

new project and add platform support has been mentioned in the previous blog, don't repeat it here.

  

  

2, the use of bower

  first confirm whether Bower is installed,if not installed, open cmd name, enter npm install-g Bower.

Open The cmd command, enter Bower install Ngcordova, if the following message appears, the computer does not have gitinstalled, because the source code for Bower managed packages is hosted on the GitHub website.

Git installation, you can enter git for Windows directly in the search engine , download a git installation file, click Install, and put Git.exe Add to the environment variable, or you can download the GitHub Client tool directly,Gitshell. Specific installation methods can be self-search on the internet.

Here, by the way Bower Install JS Library, delete JS Library, see the way to install JS Library (The following three steps are not necessary, just as a small episode):

Enter the Bower install jquery command, install the jquery library file, and if the following information appears, the installation is successful:

  

Enter Bower list to view the installed JS library file:

  

Enter Bower Uninstall jquery to delete the JS library file you just installed:

  

Then enter the Bower List command and we will find that the jquery installation is no longer in the directory:

  

3, Installation Ngcordova

  switch to the project directory, enter Bower install Ngcordova, the following message appears: (Some of the information in the picture is omitted, only the head and tail information).

  

For more information, refer to:http://www.haomou.net/2015/01/05/2015_ionic_ngCordova/

4. Add Camera Plugin

  switch to the project directory, enter the Cordova plugin add cordova-plugin-camera command, and the following message appears, indicating that the installation was successful:

More plugin information:http://ngcordova.com/docs/plugins/camera/

5. Modify the project

  after all the preparations have been completed, open the new Project project with the editor (I use webstorm here),

The first step: index.html manually introduced in Ng-cordova.js file.

Step Two: add Ngcordova dependencies in the controllers .

Step three: Add a button on the Details page to trigger a call to the camera operation.

Fourth step: add the Getcamera method to the controller that corresponds to the details page .

  

Fifth step: in cmd , enter the engineering directory, enter the Ionic run Android command, run on the phone.

6.

Phonegap+cordova+ionic calling native API

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.