我是离子2的新手,我正在尝试创建自定义信息窗口,因此当用户点击标记时,他们可以看到一些基本信息,如图片和位置名称,但他们也可以点击链接infoWindow打开一个模式,其中包含该位置的详细信息.这是我想如何将它添加到我的标记.
addMarker(lat: number, lng: number, place: any): void {
let latLng = new google.maps.LatLng(lat, lng);
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: latLng,
title: place.name
});
let infoWindow = new google.maps.InfoWindow({
content: `<>custom template here with some basic details</>`
});
marker.addListener('click', ()=> {
infoWindow.open(this.map, marker);
});
this.markers.push(marker);
}
Run Code Online (Sandbox Code Playgroud) 如何订阅完成事件,即我想在选择日期后调用一个函数.我怎么能在ionic2中做到这一点
<ion-icon class="moreicon" name="funnel">
<ion-datetime type="button" [(ngModel)]="myDate" (click)="getData()"></ion-datetime>
</ion-icon>
Run Code Online (Sandbox Code Playgroud)
在ts文件中我调用了这个函数但我的问题是在第一次选择日期时我的数据没有被过滤.再次,当我点击过滤器图标,然后显示我的过滤数据.所以我想在datetime选择器中订阅done事件.我怎样才能做到这一点??
我在这里搜索了一些但是找不到答案.
有人知道这个并且可以解释Ionic如何处理它吗?
我想在Ionic 2中自定义警报.我知道我可以在variables.scss中全局完成,但我想在特定页面中修改特定的警报.
我在警报代码中尝试了cssClass,我尝试了其他不同的东西,但是在全局范围内,而不是特定的.
有什么办法吗?
如何预填充Ionic 2离子输入区域?
我尝试过以下但是这个领域仍然空白.
<ion-input type="text" [(ngModel)]="product.content" name="content" value="123" required></ion-input>
Run Code Online (Sandbox Code Playgroud) 我已经按照本教程概述了在Ionic 2应用程序中添加监控信标.我有它工作得很好:当视图加载时,它初始化并开始监听信标:
home.ts
ionViewDidLoad() {
this.platform.ready().then(() => {
this.beaconProvider.initialise().then((isInitialised) => {
if (isInitialised) {
this.listenToBeaconEvents();
}
});
});
}
Run Code Online (Sandbox Code Playgroud)
这将调用listenToBeaconEvents函数,该函数使用所有信标填充视图中的列表:
home.ts
listenToBeaconEvents() {
this.events.subscribe(‘didRangeBeaconsInRegion’, (data) => {
// update the UI with the beacon list
this.zone.run(() => {
this.beacons = [];
let beaconList = data.beacons;
beaconList.forEach((beacon) => {
let beaconObject = new BeaconModel(beacon);
this.beacons.push(beaconObject);
});
});
});
}
Run Code Online (Sandbox Code Playgroud)
我可以使用this.beaconProvider.stopRanging()以下函数调用函数来停止测距:
信标provider.ts
stopRanging() {
if (this.platform.is('cordova')) {
// stop ranging
this.ibeacon.stopRangingBeaconsInRegion(this.region)
.then(
() => {
console.log('Stopped …Run Code Online (Sandbox Code Playgroud) 我将cli更新为离子3版本,当我运行时
离子cordova运行android
构建apk文件并在android模拟器中运行我收到此错误
C:\Users\XXXX\Desktop\beep>ionic cordova run android
Running app-scripts build: --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser
[20:52:20] build dev started ...
[20:52:20] clean started ...
[20:52:20] clean finished in 11 ms
[20:52:20] copy started ...
[20:52:20] transpile started ...
[20:52:22] transpile finished in 2.53 s
[20:52:22] preprocess started ...
[20:52:22] deeplinks started ...
[20:52:23] deeplinks finished in 52 ms
[20:52:23] preprocess finished in 54 ms
[20:52:23] webpack started ...
[20:52:23] copy finished in …Run Code Online (Sandbox Code Playgroud) 颜色属性在离子2中不起作用.颜色在普通IONIC标签中起作用,但在HTM1标签中起作用.你能帮忙吗?代码写在下面.
<ion-content>
<div class="page-home">
<h1 color="secondary">LOGO</h1>
<br/>
<br/>
<p color="danger">Sign in with social media account</p>
<div id="socialLogin">
<img src="assets/icon/fb.svg" />
<img src="assets/icon/tw.svg" />
<img src="assets/icon/goo.svg" />
</div>
<ion-list>
<ion-item>
<ion-label floating color="secondary">Username</ion-label>
<ion-input type="text"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Password</ion-label>
<ion-input type="password"></ion-input>
</ion-item>
</ion-list>
<br/>
<br/>
<button ion-button full icon-left> <ion-icon name="log-in"></ion-icon>Login</button>
<button ion-button clear>Register</button>/
<button ion-button clear>Forgot Passowrd</button>
</div>
</ion-content>
Run Code Online (Sandbox Code Playgroud) 我几天前下载了Ionic 3,当我尝试使用的每个离子命令(离子信息,离子发射,离子启动等)之后,昨天突然出现这个错误,一切正常.
{FatalException错误(C:\ Users\X\AppData\Roaming \npm \node_modules\ionic \node_modules\@ionic\cli-utils\dist\lib\errors.js:8:23)在FatalException(C:在Config上的\ Users\X\AppData\Roaming \npm \node_modules\ionic \node_modules\@ionic\cli-utils\dist\lib\errors.js:17:9).(C:\ Users\X\AppData\Roaming \npm \node_modules\ionic \node_modules\@ionic\cli-utils\dist\lib\config.js:41:31)throw(native)at rejected(C:\ Users\X\AppData\Roaming \npm \node_modules\ionic \node_modules\@ionic\cli-utils\dist\lib\config.js:5:65)name:'Exception',exitCode:1,fatal:true}
我试图删除离子和cordova并使用我在网上找到的许多不同说明重新安装多次:
npm uninstall cordova ionic
npm cache clean -f
npm install npm -g
npm uninstall node
apt-get purge npm
apt-get install npm
npm install node -g
Run Code Online (Sandbox Code Playgroud)
我也试图删除并重新安装节点,但这个错误保留在我试过的每个版本的离子3.XX.另一方面,离子2工作得很好.任何想法可能导致了什么以及如何解决它?
我正在使用:
在我的Ionic2应用程序中,我有一个处理所有http请求的服务.当http调用中发生任何错误时,我有一个警报控制器.在按钮上单击此警报我想再次运行该调用.我现在能够做到.问题是响应未解析为从哪个函数调用的页面.
服务代码:
loadCity(){
return new Promise(resolve => {
this.http.get(url).map(res=>res.json())
.subscribe(data => {resolve(data)},
err => { this.showAlert(err); }
});
}
showAlert(err: any){
// code for alert controller, I am only writing handler of alert
//controller refresh button
handler => {this.loadCity();}
}
Run Code Online (Sandbox Code Playgroud)
CityPage中的代码
showCity(){
this.cityService.loadCity()
.then(data => {//process data});
}
Run Code Online (Sandbox Code Playgroud)
处理程序再次调用函数,但此时承诺未解析为CityPage showCity()函数.
ionic-framework ×10
ionic2 ×9
angular ×2
cordova ×2
ionic3 ×2
typescript ×2
android ×1
css ×1
fatal-error ×1
google-maps ×1
html ×1
http ×1
ibeacon ×1
ionic-popup ×1
javascript ×1
npm ×1
promise ×1
sass ×1