Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Pipe operator || on the template causes error #1487

Open
zepelega opened this issue Jan 4, 2025 · 2 comments
Open

Using Pipe operator || on the template causes error #1487

zepelega opened this issue Jan 4, 2025 · 2 comments

Comments

@zepelega
Copy link

zepelega commented Jan 4, 2025

🐞 bug report

Is this a regression?

Yes, the previous version that I had installed in which this bug was not present was: "ngx-mask": "^18.0.0",

Description

When using the ||(OR) operator this error is thrown and noting is displayed.

phone: string = '9999999999'

{{ phone | mask: '(00) 0000-0000||(00) 0.0000-0000' }}

A single mask work fine, as expected.

{{ phone | mask: '(00) 0000-0000' }}

🔥 Exception or Error




ERROR RuntimeError: NG0600: Writing to signals is not allowed in a `computed`.
    at ClienteListarComponent_Conditional_27_Defer_0_td_11_Template (listar.component.html:90:41)

🌍 Your Environment

"ngx-mask": "^19.0.6"

Angular Version:




Angular CLI: 19.0.6
Node: 20.13.1
Package Manager: npm 10.8.0
OS: win32 x64

Angular: 19.0.5
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router     

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1900.6
@angular-devkit/build-angular     19.0.6
@angular-devkit/core              19.0.6
@angular-devkit/schematics        19.0.6
@angular/cdk                      19.0.4
@angular/cli                      19.0.6
@angular/material                 19.0.4
@angular/material-luxon-adapter   19.0.4
@schematics/angular               19.0.6
rxjs                              7.8.1
typescript                        5.6.3
zone.js                           0.15.0
@zepelega zepelega changed the title Using Pipe separator || on the template causes error Using Pipe operator || on the template causes error Jan 4, 2025
@Lorena301
Copy link

Hi, I have the same issue after updating to version 19. Have you been able to solve it?

@DanielNovaesDias
Copy link

DanielNovaesDias commented Jan 26, 2025

It seems commit #1467 broke the pipe, Idk the specifics or how angular works internally, but I assume angular is treating 'transform' as a computed signal, and writing to signals inside it is disallowed. Don't know how I would keep this as a signal without breaking it, could we revert this in the mean time?

also, according to this issue: angular/angular#56401, there isn't a benefit to using signals inside pure pipes, as they won't be re-evaluated.

As a temporary fix, i'm using the service to apply the mask in the TS file.

 maskService = inject(NgxMaskService);

  maskedCellphone = computed(() => {
    if (!this.unidadeInfo().Telefone) return '';

    return this.maskService.applyMask(
      this.unidadeInfo().Telefone,
      '(00) 0000-0000||(00) 00000-0000',
    );
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants