
- Ionic 基礎教程
- Ionic - 首頁
- Ionic - 概述
- Ionic - 環境搭建
- Ionic CSS 元件
- Ionic - 顏色
- Ionic - 內容
- Ionic - 頁首
- Ionic - 頁尾
- Ionic - 按鈕
- Ionic - 列表
- Ionic - 卡片
- Ionic - 表單
- Ionic - 開關
- Ionic - 複選框
- Ionic - 單選按鈕
- Ionic - 滑塊
- Ionic - 選擇框
- Ionic - 標籤頁
- Ionic - 網格
- Ionic - 圖示
- Ionic - 內邊距
- Ionic Javascript 元件
- Ionic - JS 動作面板
- Ionic - JS 背景
- Ionic - JS 內容
- Ionic - JS 表單
- Ionic - JS 事件
- Ionic - JS 頁首
- Ionic - JS 頁尾
- Ionic - JS 鍵盤
- Ionic - JS 列表
- Ionic - JS 載入
- Ionic - JS 模態框
- Ionic - JS 導航
- Ionic - JS 氣泡提示框
- Ionic - JS 彈出框
- Ionic - JS 滾動
- Ionic - JS 側邊選單
- Ionic - JS 滑塊
- Ionic - JS 標籤頁
- Ionic 高階概念
- Ionic - Cordova 整合
- Ionic - AdMob
- Ionic - 相機
- Ionic - Facebook
- Ionic - 應用內瀏覽器
- Ionic - 原生音訊
- Ionic - 定位
- Ionic - 媒體
- Ionic - 啟動畫面
- Ionic 有用資源
- Ionic - 快速指南
- Ionic - 有用資源
- Ionic - 討論
Ionic - Cordova 整合
Cordova 提供了ngCordova,這是一組專門為與 AngularJS 協同工作而設計的包裝器。
安裝 ngCordova
當你啟動 Ionic 應用時,你會注意到它使用了bower。它可以用於管理 ngCordova 外掛。如果你已經安裝了 bower,請跳過此步驟;如果沒有,你可以在命令提示符視窗中安裝它。
C:\Users\Username\Desktop\MyApp> npm install -g bower
現在我們需要安裝ngCordova。在命令提示符視窗中開啟你的應用。以下示例用於位於桌面上名為MyApp的應用。
C:\Users\Username\Desktop\MyApp> bower install ngCordova
接下來,我們需要將 ngCordova 包含到我們的應用中。開啟index.html檔案並新增以下指令碼。務必在cordova.js之前和ionic指令碼之後新增這些指令碼。
<script src = "lib/ngCordova/dist/ng-cordova.js"></script>
現在,我們需要將 ngCordova 注入為 Angular 依賴項。開啟你的 app.js 檔案並將 ngCordova 新增到 Angular 模組。如果你使用過 Ionic 模板應用之一,你會注意到其中注入了 ionic、控制器和服務。在這種情況下,你只需在陣列末尾新增 ngCordova。
angular.module('myApp', ['ngCordova'])
你可以透過鍵入以下命令來檢查已安裝的外掛。
C:\Users\Username\Desktop\MyApp> cordova plugins ls
現在,我們可以使用 Cordova 外掛了。你可以在這裡檢視所有其他外掛 這裡。
廣告