Closed as not planned
Closed as not planned
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
Angular always call the pipe even if the previous condition is false in a @if
, eg:
@if(false && value() | test){}
In this case, because the first condition is false, se second condition can be skipped
full example
import { Component, Pipe, PipeTransform, signal } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
@Pipe({
name: 'test',
})
export class TestPipe implements PipeTransform {
transform(value: any): boolean {
console.log('TestPipe');
return value;
}
}
@Component({
selector: 'app-root',
template: `
@if(condition() && value() | test){
true
} @else {
false
}
`,
imports: [TestPipe],
})
export class App {
condition = signal(false);
value = signal(null);
}
bootstrapApplication(App);
console show:
TestPipe
expected nothing
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-zmyb1dnl
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run ng version
)
Anything else?
No response
Metadata
Metadata
Assignees
Labels
No labels