8000 Feature: extend template microsyntax to allow references · Issue #14877 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content

Feature: extend template microsyntax to allow references #14877

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

Closed
dawidgarus opened this issue Mar 2, 2017 · 12 comments
Closed

Feature: extend template microsyntax to allow references #14877

dawidgarus opened this issue Mar 2, 2017 · 12 comments
Labels
area: core Issues related to the framework runtime core: ng-template and *microsyntax feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature: votes required Feature request which is currently still in the voting phase feature Issue that requests a new feature
Milestone

Comments

@dawidgarus
Copy link

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
Currently, it is not possible using template microsyntax to create reference on template element.

Expected behavior
Template microsyntax should be extended to allow references.
Proposed syntax:

<div *ngFor="let item of list; trackBy: foo; #ref=bar" #inner="baz" class="item"></div>

should be equivalent of:

<template let-item [ngForOf]="list" [ngForTrackBy]="foo" #ref="bar">
  <div #inner="baz" class="item"></div>
</template>

Minimal reproduction of the problem with instructions
N/A

What is the motivation / use case for changing the behavior?
It will enhance the means of interaction between components and directives.
For example, with the new feature, new (cleaner IMHO) if-else syntax could be possible:

<div *myIf="condA; #aRef=myIf">if condA is satisfied</div>
<div *myIf="condB; elseOf: aRef; #bRef=myIf">if condB is satisfied but not cond A</div>
<div *myIf="true; elseOf: bRef">if neither condA nor condB are satisfied</div>

And yes, I know 4.0.0 will introduce if-else, but that's not the point.

Please tell us about your environment:

  • Angular version: 2.4.8
@DzmitryShylovich
Copy link
Contributor

#ref=bar" #inner="baz"

what is bar and baz?

@dawidgarus
Copy link
Author
dawidgarus commented Mar 2, 2017

what is bar and baz?

Just some random name directive may have as exportAs.
It's just an example of syntax, not logically correct code that does something in particular.

8000

@DzmitryShylovich
Copy link
Contributor
DzmitryShylovich commented Mar 2, 2017

I'm not following :)
Can you please add the plunker that demonstrates what you are trying to accomplish?

@dawidgarus
Copy link
Author

I'm not trying accomplish anything in particular. I wan't to introduce new syntax.
As we all know, something this:

<div *structuralDirective="value"></div>

is equivalent of this:

<template [structuralDirective]="value"><div></div></template>

Currently it's not possible to get reference to structural directive using template microsyntax:

<div *structuralDirective="value" #ref="structuralDirective"></div>

will be translated to:

<template [structuralDirective]="value"><div #ref="structuralDirective"></div></template>

That's no good, because I was to reference directive on template element. So I proposed new sytanx:

<div *structuralDirective="value;  #ref=structuralDirective"></div>

Which will work like this:

<template [structuralDirective]="value" #ref="structuralDirective"><div></div></template>

@DzmitryShylovich
Copy link
Contributor

to get reference to structural directive using template microsyntax

why? you can expose public properties via context object

@dawidgarus
Copy link
Author
dawidgarus commented Mar 2, 2017

why? you can expose public properties via context object

But they could be accessed only inside the template. As far i know, You cannot access it outside template, like this:

<div *structuralDirective="let ref"></div>
<div>{{ref}}</div>

@DzmitryShylovich
Copy link
Contributor

Ok, but there's already an issue about that #12121 :

exportAs is not supported in * directives.

@IgorMinar IgorMinar added area: core Issues related to the framework runtime feature Issue that requests a new feature labels Mar 13, 2017
@ngbot ngbot bot added this to the Backlog milestone Jan 23, 2018
@angular-robot
Copy link
Contributor
angular-robot bot commented Jun 4, 2021

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Jun 4, 2021
@angular-robot
Copy link
Contributor
angular-robot bot commented Jun 25, 2021

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added the feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors label Jun 25, 2021
@petebacondarwin
Copy link
Contributor

This is being tracked in the aggregate issue of #43485 for which we need to create a project proposal.

@alxhub
Copy link
Member
alxhub commented Mar 14, 2022

Closing due to insufficient votes.

@alxhub alxhub closed this as completed Mar 14, 2022
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime core: ng-template and *microsyntax feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature: votes required Feature request which is currently still in the voting phase feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

6 participants
0