我正在寻找许多论坛和问题,但似乎没有人问如何双击ou双击Angular/ionic 2?
在离子v1中可以使用on-double-tap(参见http://ionicframework.com/docs/api/directive/onDoubleTap/)
有没有人可能有一个提示或任何代码来捕捉离子2 /角度2上的双击事件?
也许通过HammerJS?
非常感谢你 !路易斯:)
我搜索了许多论坛,问题,在doc但找不到正确的解决方案.
使用angularfire2增加值的最佳方法是什么?
我看到我们可以使用[transaction()] []但实际上并不适用于angularfire2.还是快照?
user.service.ts
incrementLike(userToIncrementLike){
this.af.database.object('users/' + userToIncrementLike.uid).subscribe((userObject) => {
var newUser = {
likes: userObject.likes + 1
};
});
this.af.database.object('users/' + userToIncrementLike.uid).update(newUser);
}
Run Code Online (Sandbox Code Playgroud)
我也试过这种方式:
incrementLike(userToIncrementLike){
let obs = this.af.database.object('users/' + userToIncrementLike.uid);
obs.subscribe((snapshot) => {
let newValue = (snapshot.$value) ? (snapshot.$value + 1) : 1;
obs.set(newValue);
});
}
Run Code Online (Sandbox Code Playgroud)
非常感谢你的帮助和提示:)路易斯.
嗨,我已经搜索了很多个小时,我希望你能帮助我:)
如果您在Google地图上点击InfoWindow,我想显示一个页面.(使用Ionic 2的ModalController)
点击不起作用..
var infoWindow = new google.maps.InfoWindow({
content: '<h2 (click)="goToProductPage(product)">Click me</h2>'
});
goToProductPage(product :any){
let modal = this.modalCtrl.create(ProductPage, product);
modal.present();
}
Run Code Online (Sandbox Code Playgroud)
遗憾的是,这不起作用,我也尝试使用内容节点onclick="",使用javascript函数..
最好的问候,路易斯
setProductMarker(product :any, productLocation :any){
var contentWindow = "<h2 id='clickableItem'>Click me</h2>" + product.productName + "<img src='" + product.imgUrl + "' width='60' height='60' /> <br/>" + product.date
var clickableItem = document.getElementById('clickableItem');
clickableItem.addEventListener('click' , () => {
this.goToProductPage(product);
});
var productMarker = new google.maps.Marker({
position: new google.maps.LatLng(JSON.parse(productLocation).latitude, JSON.parse(productLocation).longitude), …Run Code Online (Sandbox Code Playgroud) 我正在使用离子2并试图在一个数组中排序我的数组*ngFor="".
可悲的是它抛出了一个错误,我不知道为什么,这是相关的帖子
我的烟斗看起来像这样:
import {Injectable, Pipe} from '@angular/core';
import * as _ from 'lodash';
@Pipe({ name: 'order-by' })
export class OrderByPipe {
transform(array, args) {
return _.sortBy(array, args);
}
}
Run Code Online (Sandbox Code Playgroud)
我的*ngFor:
<button ion-item *ngFor="let user of users | order-by:'likes'" >
Run Code Online (Sandbox Code Playgroud)
TypeError: Cannot read property 'toUpperCase' of undefined ("
<ion-list>
<button ion-item [ERROR ->]*ngFor="let user of users | order-by: 'likes'">
Run Code Online (Sandbox Code Playgroud)
其他人也有同样的问题.不知道为什么它不起作用..
你有可能有另一个管道来排序数组吗?:) 谢谢 !
我正在搜索如何使用服务来获取用户的数据
users.services.ts
import { AngularFire, AuthProviders, AuthMethods, FirebaseListObservable}
export class Users {
uid :string = '8fbEOShqIigfA4u84cyvJcLkv5u1';
constructor(public af: AngularFire) {}
getUserObservable(){
return this.af.database.object('/users/' + this.uid);
}
}
Run Code Online (Sandbox Code Playgroud)
在这里我的家
import { Users } from '../../services/users.service';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
user: any;
isAuthenticated: boolean = true;
constructor(private userService: Users) {}
ngOnInit(){
this.userService.getUserObservable().subscribe((userObject) => {
this.user = userObject;
console.log("result : ", this.user);
});
}
}
Run Code Online (Sandbox Code Playgroud)
在控制台我得到:
result : Object {imgLink: "blabla.jpg", money: 0, score: 0, uid: "8fbEOShqIigfA4u84cyvJcLkv5u1", …Run Code Online (Sandbox Code Playgroud) angular ×5
ionic2 ×4
angularfire2 ×2
firebase ×2
javascript ×2
directive ×1
double-click ×1
google-maps ×1
pipe ×1
sorting ×1
typescript ×1