ng-ngcordova插件 为什么要安装

在家里用NPM怎么都安装不上ionic和cordova_百度知道Cordova入门-安装常见错误 - 今日头条()
1.Cordova安装Cannot find module 'bplist-parser'问题安装完cordova出现找不到必须的模块出现原因不明,不过如果出现这个问题,我们遇到缺什么模块就安装什么模块就可以了。如图所示2.Cordova cannot add Android failed with exit code ENOENT 这是因为系统环境变量损坏了解决方案:在系统变量path如果没用下面的变量就加上%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\W3.Cordova使用build命令出错: Could not create the Java Virtual Machine.这是因为虚拟机内存不足导致的,解决方案如下:_JAVA_OPTIONS=-Xmx512M
每日更新java讲解
IT之家,数码、科技、生活。
极客公园-发现产品的价值,极客公园是国内最大的创新者社区
今日头条“头条号”官方信息发布平台
中国最大的产品经理学习、交流、分享平台;想要成为CEO,先从学做产品开始。
最新科学顶尖技术的聚集公会,发布最具权威的科技资讯。
易车购物10万买豪车 新劲炫ASX等你询底价
(C) 2016 今日头条 违法和不良信息举报电话:010-公司名称:北京字节跳动科技有限公司cordova + ionic 使用中碰到的一些问题 - AiDaRLING - 博客园
cordova&+&ionic&使用中碰到的一些问题
No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.解决办法index.html 中添加《meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"》2、ionic 隐藏 nav-bar文档上来看,需要在controller中调用&&$ionicNavBarDelegate例如 .controller('DashCtrl', function ($scope, $ionicNavBarDelegate) {&&&&$ionicNavBarDelegate.showBar(false);})但没起作用。最后在模板中使用标签方法hide-nav-bar = "true"该方法起作用。3、 ng-model 与 input 值的问题例如&&&input type="text" ng-model="querystr"ng-model绑定到$scope.querystr 时,model会根据 text输入自动变化,但在controller中将$scope.querystr=''时 ,text input的值不会产生变化。并且在使用ng-model时,无法使用angular.element(document).find(selector).val("some value");方式进行赋值。解决方法是在controller 中,设置一个结构,如$scope.queryMode ={querystr:''};在input 中绑定&&ng-model = "queryModel.querystr"则controller中重设&&&$scope.queryMode.querystr = '';绑定生效,input 清空。4、cordova插件 ,在ripple中弹出错误窗口如果安装cordova插件,如keyboard,statusbar 等, 会在ripple中抛各种错,并且每次加载会弹出窗口,让你写JSON回调, 这个是ripple的BUG,不支持自定义插件, 去掉弹窗的办法是在app.js上方,即定义angular.module()的上方写
var annoyingDialog = parent.document.getElementByIdx_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x_x('exec-dialog');
上句中的x_x 去掉,新浪自动添加的。
if (annoyingDialog) annoyingDialog.outerHTML = "";
弹窗将不再出现,但输出窗口中的ripple.js中的错误仍会,你可以过滤,也可以不管。
5、使用极光推送,按照github上的说明文档,加入插件后总是无法编译,查看
是由于 platform/android/AndroidManifest.xml &中
meta-data android:name=JPUSH_APPKEY android:value=aaabbbbmn9QITAv0Oe
重复,每次build总会生成两条键值
经查在plug/android.json 中,有两条重复生成的语句,删掉一个,即可。6、ionic关于IFAME的调用因为使用第三方接口,会造成跑到应用外的地址,ionic无法控制外部连接回到应用,因此一般使用iframe方式打开外部连接,并加一个headbar用来返回到应用,如在modal中打开外部地址如html中&《script id="login.html" type="text/ng-template"》&&&&&&&&《ion-modal-view》&&&&&&&&&&&&《ion-header-bar align-title="center" class="bar-positive"》&&&&&&&&&&&&&&&&《div class="buttons"》&&&&&&&&&&&&&&&&&&&&《button&&class="button button-clear button-icon icon ion-ios-arrow-back"》《/button》&&&&&&&&&&&&&&&&&&&&《button ng-click="closeModal()" class="button button-clear button-icon icon "》取消《/button》&&&&&&&&&&&&&&&&《/div》&&&&&&&&&&&&&&&&《h1 class="title"》LOGIN《/h1》&&&&&&&&&&&&《/ion-header-bar》&&&&&&&&&&&&《ion-content scroll="true" class="has-header no-padding"》&&&&&&&&&&&&&&&&《iframe id="ifmr2" data-tap-disabled="true" ng-src="{{chatStru.paySrc}}"》《/iframe》&&&&&&&&&&&&《/ion-content》&&&&&&&&《/ion-modal-view》《/script》controller中$scope.tt = new Date().getMilliseconds();$scope.chatStru = {&&&&&&&&paySrc: $sce.trustAsResourceUrl('http://xxx.om/testlogin.jsp?tt='+$scope.tt),&&&&&&&&token: "",&&&&&&&&hasToken: false&&&&};$ionicModal.fromTemplateUrl('login.html', {&&&&&&&&scope: $scope,&&&&&&&&animation: 'slide-in-up'&&&&}).then(function (modal) {&&&&&&&&&&&&$scope.modal =&&&&});&&&&$scope.openModal = function () {&&&&&&&&&&$scope.modal.show();&&&&};&&&&&$scope.closeModal = function () {&&&&&&&&$scope.modal.hide();&&&&};
但这样的问题是在于,页面完成后,你必须通过手动点击返回,并且无法进行数据的传递,这个在html5中其实已经有了非常完美的解决方法就是postMessage()在远端的被iframe的页面中,加入JSwindow.onload=function(){&&&&&&&&&&&&&window.parent.postMessage('logined','*');&&&&&&&&}并在inoic的controller中加入&window.addEventListener('message', function (e) {&&&&&&&&var data = e.//这里返回的是 logined,相当于传递参数回来。&&&&&&&&$scope.modal.hide();&&&&}, false);&&你会发现,你即接收到了data,同时又关闭了该modal ,而不需要手动关闭。
当然,你可以将 addEventListener() 放到&$scope.openModal&
然后在 $scope.closeModal 中 removeEventListener()
&$scope.openModal = function () {
&&&&&&&&var tt = new Date().getMilliseconds();
&&&&&&&&$scope.chatStru.paySrc = $sce.trustAsResourceUrl('/oe/testlogin.jsp?tt=' + tt);
&&&&&&&&$scope.modal.show();
&&&&&&&&window.addEventListener('message', function (e) {
&&&&&&&&&&&&var data = e.
&&&&&&&&&&&&$scope.chatStru.hasToken =
&&&&&&&&&&&&$scope.modal.hide();
&&&&&&&&}, false);
&&&&// function to close the modal
&&&&$scope.closeModal = function () {
&&&&&&&&$scope.modal.hide();
&&&&&&&&if ($scope.chatStru.hasToken) {
&&&&&&&&&&&&window.removeEventListener('message', function () { }, false);
最终可以这样写
&var handel = function (e) {
&&&&&&&&var data = e.
&&&&&&&&if (data.id & 0) { &// 传回来的为json{id:1,msg:'aaa'}
&&&&&&&&&&&&if (!$scope.chatStru.hasToken) {
&&&&&&&&&&&&&&&&$scope.chatStru.hasToken =
&&&&&&&&&&&&}
&&&&&&&&&&&&$scope.modal.hide();
&&&&&&&&} else {
&&&&&&&&&&&&$scope.chatStru.hasToken =
&&&&$scope.openModal = function () {
&&&&&&&&var tt = new Date().getMilliseconds();
&&&&&&&&$scope.chatStru.paySrc = $sce.trustAsResourceUrl('/oe/testlogin.jsp?tt=' + tt);
&&&&&&&&$scope.modal.show();
&&&&&&&&if (!$scope.chatStru.hasToken) {
&&&&&&&&&&&&window.addEventListener('message', handel, false);
&&&&$scope.closeModal = function () {
&&&&&&&&$scope.modal.hide();
&&&&&&&&if ($scope.chatStru.hasToken) {
&&&&&&&&&&&&window.removeEventListener('message', handel, false);
&&&&};7、使用android studio 运行cordova项目直接使用platfrom目录里的gradle 可以在android studio中直接导入 cordova的项目,但运行模拟器时出现Cannot&reload&AVD&list:&cvc-enumeration-valid:&Value&'280dpi'&is&not&facet-valid&with&respect&to&enumeration&'[ldpi,&mdpi,&tvdpi,&hdpi,&xhdpi,&400dpi,&xxhdpi,&560dpi,&xxxhdpi]'.&It&must&be&a&value&from&the&enumeration.Error&parsing&D:\sdkforas\android-sdk-windows\system-images\android-22\android-wear\armeabi-v7a\devices.xmlcvc-enumeration-valid:&Value&'280dpi'&is&not&facet-valid&with&respect&to&enumeration&'[ldpi,&mdpi,&tvdpi,&hdpi,&xhdpi,&400dpi,&xxhdpi,&560dpi,&xxxhdpi]'.&It&must&be&a&value&from&the&enumeration.Error&parsing&D:\sdkforas\android-sdk-windows\system-images\android-22\android-wear\x86\devices.xml解决方法 :用/sdk/tools/lib/devices.xml去替换 system-images\android-22\android-wear\x86\devices.xml和system-images \android-22\android-wear\armeabi-v7a\devices.xml中的devices.xml8、 android studio 中 gradle 失败gradle&project&sync&failed.Basic&functionality(e.g.editing,debugging)&will&not&work&properly.解决方法:android&studio中,点击&tools&-&Android-&sync&project&with&gradles&files.9、加载远程js或css&出现&Refused&to&load&the&script&&或 Refused to load the stylesheetbecause it violates&the&following ....例如 index.html中 加载字体《link href='/css?family=RobotoDraft:400,500,700,400italic' rel='stylesheet'》可在index.html添加安全许可《meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline' script-src 'self' 'unsafe-inline' 'unsafe-eval';"》直接加根域名即可,另外不要带引号 js&&需要添加在 script-src 中。10 、 ionic 中 弹出键盘遮挡住输入框在config.xml 中修改全屏为FALSE并添加&&adjustPan&&(adjstResize没有成功)&《preference name="Fullscreen" value="False" /》&&《preference name="android-windowSoftInputMode" value="adjustPan"/》11、ionic监听滚动网上的示例xxx.bind('scroll',function(){.....}),很容易将页面跑死, 换个思路,使用监听touchvar targetPos = window.screen.availH&$("#scdiv").on("touchend", function () {if (currpos & 10 && currpos & targetPos / 4) {&&&&&&&&&&&&&&&&$ionicScrollDelegate.$getByHandle('homescroll').scrollTo(0, 0, true);&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&} else if (currpos &= targetPos / 4 && currpos &= targetPos - 10) {&&&&&&&&&&&&&&&&$ionicScrollDelegate.$getByHandle('homescroll').scrollTo(0, targetPos - 64, true);&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&}})当触摸结束时,判断当前的位移,来做一些操作。这样在性能上提高了许多。$ionicScrollDelegate.$getByHandle 操作的是在html中定义的delegate-handle如《ion-content id="scdiv" delegate-handle="homescroll"》12、 APP开启检测网络并提示开启需要三个插件1、/apache/cordova-plugin-network-information2、/apache/cordova-plugin-dialogs3、/deefactorial/Cordova-open-native-settings然后在APP.JS中,divicesReady中$ionicPlatform.ready(function () {if (navigator.connection) {&&&&&&&&&&&&var tmptypes = navigator.connection.&&&&&&&&&&&&if (tmptypes.toUpperCase().indexOf('NONE') & -1 || tmptypes.toUpperCase().indexOf('UNKNOWN') & -1) {&&&&&&&&&&&&&&&&if (navigator.notification) {&&&&&&&&&&&&&&&&&&&&navigator.notification.confirm(&&&&&&&&&&&&&&&&&&&&'您的设备未开启网络',&&&&&&&&&&&&&&&&&&&&&&&function (buttonIndex) {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&if (buttonIndex == 1) {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&if (cordova.plugins.settings) {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&cordova.plugins.settings.openSetting("wifi", function () { console.log("network setting openning"); }, function () { console.log("open network setting failed"); });&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&&&&&&&&&&&&&&}&&&&&&&&&&&&&&&&&&&&&&&&&},&&&&&&&&&&&&// callback to invoke with index of button pressed&&&&&&&&&&&&&&&&&&&&&&&'提示',&&&&&&&&&&&// title&&&&&&&&&&&&&&&&&&&&&&&['开启', '取消']&&&&&// buttonLabels&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&);&&&&&&&&&&&&&&&&}&&&&&&&&&&&&}&&&&&&&&}})其中openSettings中可设置以下本地设置
var&settingNames&=&array(
&&&&"open",
&&&&"accessibility",
&&&&"add_account",
&&&&"airplane_mode",
&&&&"apn",
&&&&"application_details",
&&&&"application_development",
&&&&"application",
&&&&"bluetooth",
&&&&"captioning",
&&&&"cast",
&&&&"data_roaming",
&&&&"date",
&&&&"device_info",
&&&&"display",
&&&&"dream",
&&&&"home",
&&&&"input_method",
&&&&"input_method_subtype",
&&&&"internal_storage",
&&&&"locale",
&&&&"location_source",
&&&&"manage_all_applications",
&&&&"manage_applications",
&&&&"memory_card",
&&&&"network_operator",
&&&&"nfcsharing",
&&&&"nfc_payment",
&&&&"nfc_settings",
&&&&"print",
&&&&"privacy",
&&&&"quick_launch",
&&&&"search",
&&&&"security",
&&&&"settings",
&&&&"show_regulatory_info",
&&&&"sound",
&&&&"sync",
&&&&"usage_access",
&&&&"user_dictionary",
&&&&"voice_input",
&&&&"wifi_ip",
&&&&"wifi",
&&&&"wireless");
其中相关网络的为wifi&&移动数据开启未找到。谁试出了是哪个请告诉我13、$sate.go&&和 $stateParams 传参及收参在 controller1 中使用&&$state.go('statename',{id:1}) ;传递参数在 statename 相对应的&&controller2 中接收参数$scope.id = $stateParams.注意,此处必须在router.js 中设置 statename 的参数形式如.state('statename ', {&&&&url: '/statename ',&&&&params: { 'id': null },&&&&templateUrl: 'templates/Users/statename .html',&&&&controller: 'controller2 '})其中params: { 'id': null }, 对应$state传的参,若不设,则必为undefined14、关于ionic中想底部加一长按钮,随页面滚动位置不变,例如最初的方案是在 ion-content&&外 ion-view 内添加一层div .....style= ..... position:fixed&&&&bottom:0之类,但最终发现,在不同分辨率下位置并不正确基本可确定是因为statusbar等的缘故,仔细看了下ionic.css最终发现,太简单了div class="tabs"&&就可以了。15、php中取值问题ionic中用的$http&&method:post ,params........在PHP中用$_POST取不到值, 改成 $_Request 就行了。16、使用vs2015 release会提示使用发布配置进行调试时,Android 程序包必须已签名。要配置 Android 签名,请按照 /fwlink/?LinkID=613579 中的说明操作(该网页很难打开)实际需要在项目根目录的build.json中添加生成的keystore{&&&&&"android": {&&&&&&"release": {&&&&&&&&"keystore": "E:\\Projects\\android.keystore",&&&&&&&&"storePassword": "*******",&&&&&&&&"alias": "********",&&&&&&&&"password": "*******",&&&&&&&&"keystoreType": ""&&&&&&}&&&&&}&}至于生成keystore 请百度,只要有jdk 运行命令就OK17、ionic 的滚动优化在app.js中的config 块中,加入$ionicConfigProvider.scrolling.jsScrolling(false);默认所有的滚动使用native,会比js的滚动快很多,并且很平滑,但这样做的话,无法使用一些效果,如has-bouncing="true"(仿苹果的一种上下拉显示背景的弹性效果)那你可以在特定的view中,ion-content中加入overflow-scroll="false",则该view保持js滚动18、微信支付支付宝支付非常简单,文档也很丰富,微信的相对来说低了不止一个档次,当然最郁闷的一件事是经过了数天的查错,发现微信的totalfee 居然是以分为单位,换句话来说,你传价格时,只会有整数如果出现0.01,那必然出错。19 ion-header-bar 下总是有条横线,即使设为border:none也没有作用。经查,添加background-size: 100% 0 即可解决。Why not share the love for Angular-js ?
Get the weekly digest in your inbox:
ng-cordova
Stars : 3483
Forks : 1037
Created by
Cordova with AngularJS Goodness
ngCordova gives you simple AngularJS wrappers for a massive amount of Cordova plugins. Check out the list below for all of the available plugins, and create an issue for a new request.
Created by the
team and the community.
Requirements
bower install ngCordova or
Custom build
Installation
Install manually, or from bower:
$ bower install ngCordova
Plugins (67+)
(:warning: share % Ad revenue)
(:warning: share % Ad revenue)
(:warning: share % Ad revenue)
(:warning: share % Ad revenue)
(:warning: share % Ad revenue)
(:warning: share % Ad revenue)
(:warning: share % Ad revenue)
(:warning: share % Ad revenue)
(available separately)
(deprecated - Will be removed in future release)
[Push Notifications - V5] (/phonegap/phonegap-plugin-push)
* official Apache Cordova Plugin
Paolo Bernasconi
/paolobernasconi
/pbernasconi
Project Maintainer
George Stocker
ngCordova is licensed under the MIT Open Source license. For more information, see the LICENSE file in this repository.
Javascript plugin
Angular-js
Get the weekly digest in your inbox:

我要回帖

更多关于 ionic ngcordova 的文章

 

随机推荐