Angular documentation recommends using Angular services Angular expressions:
Instead, use services such as $ window and $ location in functions called from expressions. Such services provide mock access to global variables.
- https://docs.angularjs.org/guide/expression#context
However, these services are not displayed in scope by default, for example.
{{$location || 'Undefined'}}
Will produce "Undefined".
If I want to access a service $locationfrom a view, do I need to enter it into the scope?
function ($scope, $location) {
$scope.$location = $location;
}
Gajus source
share