Constructor for the object exposed as $browser service.
This object has two goals:
For tests we provide mock implementation
of the $browser
service, which can be used for convenient testing of the application without the interaction with
the real browser apis.
Adds a stylesheet tag to the head.
url – {string} –
Url to css file
Adds a script tag to the head.
url – {string} –
Url to js file
domId(optional) – {string} –
Optional id for the script tag
Adds a function to the list of functions that poller periodically executes, and starts polling if not started yet.
fn – {function()} –
Poll function to add
{function()}
– the added function
Register hover function to real browser
Executes a fn asynchroniously via setTimeout(fn, delay)
.
Unlike when calling setTimeout
directly, in test this function is mocked and instead of using
setTimeout
in tests, the fns are queued in an array, which can be programmatically flushed
via $browser.defer.flush()
.
fn – {function()} –
A function, who's execution should be defered.
delay(optional=0) – {number} –
of milliseconds to defer the function execution.
{*}
– DeferId that can be used to cancel the task via $browser.defer.cancel()
.
Get current browser's url
{string}
– Browser's url
Set hover listener.
listener – {function(Object, boolean)} –
Function that will be called when a hover event occurs.
callback – {function()} –
Function that will be called when no outstanding request
Detects if browser support onhashchange events and register a listener otherwise registers
$browser poller. The listener
will then get called when the hash changes.
The listener gets called with either HashChangeEvent object or simple object that also contains
oldURL
and newURL
properties.
NOTE: this api is intended for use only by the $location service. Please use the
$location service
to monitor hash changes in angular apps.
listener – {function(event)} –
Listener function to be called when url hash changes.
Sets browser's url
url – {string} –
New url
Send ajax request
method – {string} –
Requested method (get|post|put|delete|head|json)
url – {string} –
Requested url
post – {?string} –
Post data to send (null if nothing to post)
callback – {function(number, string)} –
Function that will be called on response
header(optional) – {object} –
additional HTTP headers to send with XHR. Standard headers are: