tinusn / ui-router-metatags

Metatags support for the AngularUI Router
MIT License
51 stars 18 forks source link

$window on $rootScope. #24

Open Remco75 opened 7 years ago

Remco75 commented 7 years ago

The Metatags service exposes the $window service on its object. When the implementing app puts the Metatags service on the $rootScope the whole window object is in turn exposed on the $rootScope.

This feels like a big scope pollution, and might have performance impact. as far as I can see there are 2 solutions

  1. Use a Weakmap outside the class to store $window as a 'private' member.
  2. Do not use window at all (I think it is only used for retreiving the absolute page URL, but the $state service can do that to.
Remco75 commented 7 years ago

oh a 3rd way, do not expose the derrived metatags directly on the Metatag service but rather in an obeject that you put on the service, and we put that on the rootScope

tinusn commented 7 years ago

Either solution works, feel free to create a pull request