ic-transform-response
- Transform Response attributeThis attribute is a javascript expression that will be evaluated after a response is received, allowing the client side to transform the given response (e.g. from JSON to HTML)
This attribute is a valid javascript expression, evaluated within an isolated scope.
This attribute may be placed on parent elements, allowing you to specify behavior across multiple elements.
Available symbols are:
content
- The string content of the server responseurl
- The URL that the content came fromelt
- The element that triggered the requestThe ic-transform-response
attribute can be placed on an parent element, allowing general request processing
for an entire page. Intercooler will find the closest element with this attribute and evaluate it.
Note that, due to the way intercooler evaluates expressions, you must include a return
statement in this attribute to return the value.
Here is a simple example, using a poll interval to update a list coming from a JSON end point and ic-transform-response
to convert that JSON into HTML:
<ul ic-get-from="/ips" ic-poll="1s" ic-transform-response="return jsonToHTML(content)"> <li>No Data Yet...</li> </ul>