$cordovaDialogs使用时遇到的问题
1:按照http://ngcordova.com/docs/plugins/dialogs/文档介绍进行安装使用:
//标题栏 .controller('TitleCtrl', function($scope,$cordovaDialogs,$ionicHistory){ $scope.wzhGoBack = function(){ $ionicHistory.goBack(); }; $scope.wzhCloseApp = function(){ $cordovaDialogs.confirm('您确定要退出系统?', '友情提示', ['确定','取消']) .then(function(buttonIndex) { // no button = 0, 'OK' = 1, 'Cancel' = 2 if (buttonIndex == 1) { ionic.Platform.exitApp(); } }); $cordovaDialogs.beep(3); }; })
运行在手机上只显示了标题栏,下面的界面没有了,通过运行ionic serve在网页上报错信息如下:
ionic.bundle.js:21157 Error: [$injector:unpr] Unknown provider: $cordovaDialogsProvider <- $cordovaDialogs <- TitleCtrl http://errors.angularjs.org/1.4.3/$injector/unpr?p0=%24cordovaDialogsProvider%20%3C-%20%24cordovaDialogs%20%3C-%20TitleCtrl at ionic.bundle.js:8895 at ionic.bundle.js:13089 at Object.getService [as get] (ionic.bundle.js:13236) at ionic.bundle.js:13094 at getService (ionic.bundle.js:13236) at Object.invoke (ionic.bundle.js:13268) at extend.instance (ionic.bundle.js:17826) at nodeLinkFn (ionic.bundle.js:16936) at compositeLinkFn (ionic.bundle.js:16368) at nodeLinkFn (ionic.bundle.js:16972)
2:需要安装ngCordova
参照:http://ngcordova.com/docs/install/
(1)index.html
<script src="lib/ngCordova/dist/ng-cordova.min.js"></script> <script src="cordova.js"></script>
(2)app.js
angular.module('starter',
[
'ionic',
'starter.controllers',
'starter.services',
'ngCordova'
]
)