小编lui*_*ill的帖子

双击/双击Angular2和离子

我正在寻找许多论坛和问题,但似乎没有人问如何双击ou双击Angular/ionic 2?

在离子v1中可以使用on-double-tap(参见http://ionicframework.com/docs/api/directive/onDoubleTap/)

有没有人可能有一个提示或任何代码来捕捉离子2 /角度2上的双击事件?

也许通过HammerJS?

非常感谢你 !路易斯:)

directive double-click ionic2 angular2-directives angular

8
推荐指数
2
解决办法
2万
查看次数

angularfire2增加值的最佳方法?

我搜索了许多论坛,问题,在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)

非常感谢你的帮助和提示:)路易斯.

firebase ionic2 angular2-services angularfire2 angular

6
推荐指数
3
解决办法
3157
查看次数

单击InfoWindow Typescript Angular2

嗨,我已经搜索了很多个小时,我希望你能帮助我:)

理念

如果您在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)

javascript google-maps typescript ionic2 angular

3
推荐指数
1
解决办法
2656
查看次数

Angular 2 Pipe参数失败

我正在使用离子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)

其他人也有同样的问题.不知道为什么它不起作用..

你有可能有另一个管道来排序数组吗?:) 谢谢 !

javascript sorting pipe ionic2 angular

2
推荐指数
1
解决办法
3338
查看次数

使用Ionic获取angularfire2中的当前用户数据

我正在搜索如何使用服务来获取用户的数据

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)

firebase firebase-authentication angularfire2 angular

1
推荐指数
1
解决办法
2071
查看次数