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

make $location getters easily observable #643

Closed
IgorMinar opened this issue Nov 8, 2011 · 4 comments
Closed

make $location getters easily observable #643

IgorMinar opened this issue Nov 8, 2011 · 4 comments

Comments

@IgorMinar
Copy link
Contributor

if we removed this references from $location getters, we could write scope.$watch($location.url, ..) instead of scope.$watch(function() { return $location.url() }, ...)

this should be a trivial change

@colincasey
Copy link
Contributor

since the $location functions determine whether the getter or setter is being called by checking if the first argument is undefined, wouldn't registering scope.$watch($location.url, ...) pass the scope as the first argument in the digest loop and effectively set that as the value?

@petebacondarwin
Copy link
Contributor

@colincasey - you are right.

For the "properties" that are "Getter-Setter": path, hash, search, url, this would not work, unless we provided separate "read-only" versions of them.
The ones that are read-only would work: absUrl, protocol, host, port.

Probably makes this idea much less trivial

@colincasey
Copy link
Contributor

@petebacondarwin, definitely less trivial. i played around with this for awhile yesterday and was able to get the function bindings for all the location properties to work with scope.$watch($location.url, ...) but the setters really complicate the picture.

the only other way i could think to make this work would be to also check the first argument to see if it was a Scope object and call the getter in that case but that seems awkward and unwise.

@petebacondarwin
Copy link
Contributor

I wonder if it is any real benefit to spend time on this. It is only syntactic sugar and also $watch will be moving towards using Object.observe in the long run which could make this redundant.

@Narretz Narretz modified the milestones: Ice Box, Backlog Jul 11, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants