Ionic跳转到外网地址
2024-10-07 23:55:01
1.安装插件
https://github.com/apache/cordova-plugin-inappbrowser
执行命令:
cordova plugin add org.apache.cordova.inappbrowser
采用命令查看:
cordova plugin ls
2.简单代码
$scope.godetail=function(unit){
var options = {
location: 'yes',
clearcache: 'yes',
toolbar: 'no'
};
var reg=/^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$/;
if(reg.test(unit.DetailAddr)){
$cordovaInAppBrowser.open(unit.DetailAddr, '_blank', options)
.then(function(event) {
// success
})
.catch(function(event) {
// error
});
//$cordovaInAppBrowser.close();
}
else{
$ionicLoading.show({
noBackdrop: true,
template: "地址错误",
duration: 1500
});
}
}
$rootScope.$on('$cordovaInAppBrowser:loadstart', function(e, event){
alert("I安装中了");
});
<div class="card">
<div class="item">
<strong>{{HelpProc.RescueModel.UnitName}} <label class="price">¥{{HelpProc.RescueModel.Amount}}</label></strong>
<div class="item" ng-repeat="unit in HelpProc.RescueModel.ListRescue" ng-click="godetail(unit)">
<span > {{unit.UnitName}}</span>
<div class="clearfix"></div>
<p class="align_right "><label class="labgreen">¥{{unit.Amount}} {{unit.DtTime}}</label></p>
</div>
</div>
</div>
3.效果图
备注:这个是ngcordova 的写法,cordova 写法参考其它
参考地址:
http://www.ionic-china.com/doc/ngCordova/In%20App%20Browser.html
http://cordova.apache.org/docs/en/3.3.0/cordova/inappbrowser/inappbrowser.html
最新文章
- win7默认网关不可用怎么解决
- 转:Git 求生手册 - 第三章分支工作
- A trip through the Graphics Pipeline 2011_12 Tessellation
- 枚举 POJ 1753 Flip Game
- hadoop mapred-queue-acls 配置(转)
- 【分享】SQL Server优化50法
- 转: css3: display:box详解
- apk反汇编之smali语法
- sql server 2008 数据库管理系统使用SQL语句创建登录用户详细步骤
- 纯css实现select下拉框并排显示
- FaaS技术框架
- Codeforces Round 504
- Tomcat服务安全加固
- 安卓中使用OkHttp发送数据请求的两种方式(同、异步的GET、POST) 示例-- Android基础
- eclipse打开出现Failed to create the java virtual machine
- cygwin简介及使用
- 保存登录plsql developer 的用户名和密码
- 【git】 linux 环境安装git
- spring boot 静态变量注入配置文件
- Unix 网络编程 读书笔记3