Title: feat(compiler): Support instanceof operator in Built-in control flow (Angular templates) · Issue #59975 · angular/angular · GitHub
Open Graph Title: feat(compiler): Support instanceof operator in Built-in control flow (Angular templates) · Issue #59975 · angular/angular
X Title: feat(compiler): Support instanceof operator in Built-in control flow (Angular templates) · Issue #59975 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? compiler Description I'm interested in hearing opinions on allowing the use of the instanceof operator within the @if control block. Sometimes, I want to expose a t...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? compiler Description I'm interested in hearing opinions on allowing the use of the instanceof operator within the @if contro...
X Description: Which @angular/* package(s) are relevant/related to the feature request? compiler Description I'm interested in hearing opinions on allowing the use of the instanceof operator within the @if co...
Opengraph URL: https://github.com/angular/angular/issues/59975
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat(compiler): Support instanceof operator in Built-in control flow (Angular templates)","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\n\ncompiler\n\n### Description\n\nI'm interested in hearing opinions on allowing the use of the instanceof operator within the @if control block. Sometimes, I want to expose a template based on the instance of an object rather than its properties. \n\nWhile Angular templates is designed with a declarative UI composition in mind, I wonder if instanceof might not be considered declarative enough. If there is any reason for not considering it, could it be related to performance or debugging concerns?\n\nExample:\n\n```html\n@if(myObject instanceof SomeClass) {\n \u003c!-- This template will only be displayed if myObject is an instance of SomeClass --\u003e\n \u003cdiv class='some'\u003e\n Content for SomeClass instance.\n \u003c/div\u003e\n}\n\n```\n\n### Proposed solution\n\nHere is a [stackblitz](https://stackblitz.com/edit/ngifin-fcj1cnex?file=src%2Fapp%2Fapp.component.html)\n\n### Alternatives considered\n\nPre-Computed Properties: Compute the instanceof result in the component and bind it to the template.\nCustom Pipe: Use a custom pipe to encapsulate the instanceof logic.\nCustom Structural Directive: Create a directive to handle the instanceof check declaratively.","author":{"url":"https://github.com/sunio00000","@type":"Person","name":"sunio00000"},"datePublished":"2025-02-17T09:40:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/59975/angular/issues/59975"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:29d3fa9a-026a-a9f5-cb2d-90ea88a3ab5c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A43E:2D3E84:2C19750:3CC11D7:6964EC81 |
| html-safe-nonce | d8acc037601915fe35efc0c39a9af9c05c53be7f866048d0f7a9701746a7de6e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDNFOjJEM0U4NDoyQzE5NzUwOjNDQzExRDc6Njk2NEVDODEiLCJ2aXNpdG9yX2lkIjoiMjcxODY3NjQyMjgxOTYzODQwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cea93ee0c8744e1bcd414631b3ed48f3970d824d9d5468cbe9d586274bc4b1cf |
| hovercard-subject-tag | issue:2857301345 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/59975/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2da9c527bb7746e474f39ff5d40df7fbd373a0fed65f5aad54fc6a006ff7971c/angular/angular/issues/59975 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2da9c527bb7746e474f39ff5d40df7fbd373a0fed65f5aad54fc6a006ff7971c/angular/angular/issues/59975 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? compiler Description I'm interested in hearing opinions on allowing the use of the instanceof operator within the @if contro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sunio00000 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 53cd8ae9b65b7c4a0ad545ffeb3216839259a92733857ba426906c0655c5419d |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c140758368c0a01881f61b83770bd75cfe81e2c4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width