收集一下phonegap路上的坑和坎
解决1:需要在controller中定义一个对象,使用对象的属性,才能进行跨scope数据传递。
解决2:通过$parent访问上层scope
phonegap 打包APP后无网络 404 错误
1,检查是否有cordova-plugin-whitelist插件
ionic plugin list
2,如果有,检查config.xml是否有access配置,一般配置为就行了
<access origin=”“/>
3,如果没有cordova-plugin-whitelist插件,安装它
cordova plugin add cordova-plugin-whitelist
4,然后配置access网络白名单
分离Controller需要注意
var myApp = angular.module(‘myApp’,[]);
会创建一个Module,如果分controllers.js分件,只有第一个加载的js文件中需要创建,后面的不需要再次创建,否则会丢失上一个加载的module。
var myApp = angular.module(‘myApp’);
不会创建新的module对象
问:angular-ui-router,$state.go如何带参数?
1.在App.js的状态机定义中,添加params项,写上要传递的参数名和默认值
//用户中心 我的订单
.state('tab.user-myOrders', {
url: '/user/myOrders',
views: {
'tab-usercenter': {
templateUrl: 'templates/user/myOrders.html',
controller: 'UserOrderCtrl',
},
},
params: {param:0}
})
2.在$state.go函数中添加要传递的参数值
$state.go(“tab.user-myOrders”,{param:288});
3.在新页面的controller中,定义$stateParams,获取参数
$stateParams.param;