相关疑难解决方法(0)

数字Pipe - Angular 2的参数是什么

我使用下面的数字管道将数字限制为两位小数.

{{ exampleNumber | number : '1.2-2' }}
Run Code Online (Sandbox Code Playgroud)

我想知道'1.2-2'背后的逻辑是什么?我玩过这些尝试实现一个过滤到零小数位的管道,但无济于事.

pipe decimal angular

108
推荐指数
4
解决办法
9万
查看次数

使用简单的管道限制为2位小数

我找到了一个将数字限制为2位小数并将数字转换为货币数量的示例 - 例如£2.55.

{{ number | currency : 'GBP' : true : '1.2-2'}}
Run Code Online (Sandbox Code Playgroud)

是否有一个简单的管道在不使用货币的情况下也能做到这一点?

pipe decimal angular

74
推荐指数
4
解决办法
10万
查看次数

使用Firebase重新验证

我将非常感谢有关如何在Firebase中重新验证用户的帮助.如果文档没有解释如何使用它,我想知道添加所有这些强大的功能是否有任何意义:

目前,这正是我正在尝试的,而且它无法正常工作.错误如cannot read property 'credential' of undefined

在构造函数中:

  constructor(@Inject(FirebaseApp) firebaseApp: any) {
    this.auth = firebaseApp.auth();
    console.log(this.auth);
  }
Run Code Online (Sandbox Code Playgroud)

那么功能

changePassword(passwordData) {
    if(passwordData.valid) {
      console.log(passwordData.value);
      // let us reauthenticate first irrespective of how long
      // user's been logged in!

      const user = this.auth.currentUser;
      const credential = this.auth.EmailAuthProvider.credential(user.email, passwordData.value.oldpassword);
      console.log(credential);
      this.auth.reauthenticate(credential)
        .then((_) => {
          console.log('User reauthenticated');
          this.auth.updatePassword(passwordData.value.newpassword)
            .then((_) => {
              console.log('Password changed');
            })
            .catch((error) => {
              console.log(error);
            })
        })
        .catch((error) => {
          console.log(error);
        })
    }
  }
Run Code Online (Sandbox Code Playgroud)

javascript firebase firebase-authentication angularfire2

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

数字过滤器过滤器数量减少到两位小数,但不会以这种方式显示

这就是我所看到的:

该值设置为160.90,但显示为160.8999999999等.

<input class="form-control" ng-model="imprint.total" 
    value="{{imprint.total | number:2}}" readonly>
Run Code Online (Sandbox Code Playgroud)

它通过过滤某些输入来获得总数,但实质上它只是一个价格乘以数量.

angularjs angularjs-filter

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