Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat(compile): add human readable alternative to '@=&?' #9137

Closed
wants to merge 1 commit into from
Closed

feat(compile): add human readable alternative to '@=&?' #9137

wants to merge 1 commit into from

Conversation

shahata
Copy link
Contributor

@shahata shahata commented Sep 17, 2014

support using interpolate:<name>, bind:<name>, eval:<name> and bind:optional:<name> instead of @<name>, =<name>, &<name> and =?<name>

Closes #9125

@caitp
Copy link
Contributor

caitp commented Sep 17, 2014

it looks alright to me, I think we do need another core team opinion on this though --- @tbosch wdyt?

@caitp caitp added this to the 1.3.0 milestone Sep 17, 2014
expect(componentScope.optRefAlias).toBe(componentScope.optRef);
expect(componentScope.optRefAlias).toBe(undefined);
expect(componentScope.optRefVerbose).toBe(undefined);
expect(componentScope.optRefAliasVerbose).toBe(undefined);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above 4 checks are incorrect (not just the new "verbose" ones, but the old ones as well).
We are checking against componentScope.optRef[XYZ], but they will always be undefined, because there are no such properties on componentScope.

We should be checking against componentScope.optref[XYZ] (notice the lowercase r), because these are the properties that will eventually get values, so these are the ones we want to ensure are undefined before $rootScope.name gets a value assigned.

(The rest of the it block uses optref[XYZ] correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. thanks.

support using `interpolate:<name>`, `bind:<name>`, `eval:<name>` and `bind:optional:<name>` instead of `@<name>`, `=<name>`, `&<name>` and `=?<name>`

Closes #9125
@btford
Copy link
Contributor

btford commented Sep 22, 2014

@tbosch thoughts? I like the syntax better, but idk if it's really worth changing Angular 1.x to have yet another way to do this...

@caitp
Copy link
Contributor

caitp commented Sep 22, 2014

agree that having multiple ways to do it kind of sucks, but if we're going to do it, then this doesn't look like a bad way

@tbosch
Copy link
Contributor

tbosch commented Oct 3, 2014

Just talked to @IgorMinar, for now we don't do this as it adds another way to do the same thing. Would need to keep both in sync, update the style guide, ...

But we should document why we use those symbols

  • @: access attributes just like in css selectors
  • &: from C to keep a reference to a function
  • =: obvious

@tbosch
Copy link
Contributor

tbosch commented Oct 3, 2014

@shahata Could you create a docs PR instead with these explanations?

@caitp
Copy link
Contributor

caitp commented Dec 10, 2014

@shahata ping --- did you ever submit docs PRs about this? Someone on the IRC channel was saying we really need better docs/more examples for the isolate scope variable symbols.

@shahata
Copy link
Contributor Author

shahata commented Dec 13, 2014

Sorry, somehow missed this one. I have to say that the reasoning behind the symbols doesn't make it any easier to understand imo. Even for me it sounds a bit strange:

  1. Where do we use @ in css selectors? The only use of @ in css that I'm aware of is for instructions. Maybe @ is taken from xpath but still I don't think it will help a lot of people to understand.
  2. I'm an old C hacker, so I'm pretty sure & is for getting the address of a variable (and in C++ for passing function arguments by reference), so I don't get the analogy and I don't think many people will...

I think we'd better close this unless someone has a good suggestion regarding how the docs can be improved.

@googlebot
Copy link

CLAs look good, thanks!

@lgalfaso
Copy link
Contributor

lgalfaso commented Jan 2, 2015

Based on #9137 (comment), this is not going to land

@rcollette
Copy link

What a shame this was dismissed. When you read blogs, instructional videos,etc this is commonly discussed as a pain point. Keeping documentation up to date is a lame excuse for not implementing a small but helpful bit of code. I sense that fragile egos related to the original design are more the issue. Not one reason was presented for using symbology here and not elsewhere in angular, yet were going to hold on to it.

@lgalfaso
Copy link
Contributor

lgalfaso commented Jan 2, 2015

@rcollette please keep the conversation technical and follow the code of conduct

@rcollette
Copy link

My apologies

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

Successfully merging this pull request may close these issues.

Request: Human-readable alternatives to '@=&' in custom directive scope:{} definitions
10 participants