Wednesday, 7 January 2015

Angularjs $location path vs $location url vs windows.location




https://docs.angularjs.org/guide/$location


Comparing $location to window.location

window.location$location service
purposeallow read/write access to the current browser locationsame
APIexposes "raw" object with properties that can be directly modifiedexposes jQuery-style getters and setters
integration with angular application life-cyclenoneknows about all internal life-cycle phases, integrates with $watch, ...
seamless integration with HTML5 APInoyes (with a fallback for legacy browsers)
aware of docroot/context from which the application is loadedno - window.location.pathname returns "/docroot/actual/path"yes - $location.path() returns "/actual/path"



$location.url('/Login') to navigate to that route.
For locations outside of the Angular app (ie no route defined), plain old JavaScript will server:
window.location = "http://www.domain.com/login"




















































No comments:

Post a comment