I'm trying to get the AngularJS to work together with XSLT, but having issues with such a simple thing as showing a hello world instead of {{data binding}}.
Is it even possible to get AngularJS to work with XSLT?
There shouldn't really be a lot of hurdles to overcome - what one needs to remember is that there's a couple of things you need to think of when generating the output:
Switch to HTML output mode to make sure you're not getting empty <script> or <div> tags in the output
You do that at the top of the file:
<xsl:output method="html" ... />
Because curlies inside attributes (and only in attributes) are already used for something similar in XSLT, you need to escape them by doubling them to generate them in the output
It's only when used inside of an attribute that you need to escape the curlies - I didn't make that obvious enough, I see.
(So this one only needs the regular set of double-curlies to work - the previous probably failed because of the critical angular.js<script> tag being closed as <script /> which is known to fail in atleast a couple of browsers...)
EDIT: Oh, and you obviously need to run this from a webserver, because of the use of the protocol-less URL (//) for the AngularJS file...
I found the issue has nothing to do with AngularJS and XSLT at all, but the order of AngularJS and jQuery. I was calling jQuery at first and thereafter AngularJS. When I changed the order of these everything worked just fine.
Thanks to all the help you, Mads and Ismail provided.
Looking so forward to work with AngularJS. Per has really sold the idea of the magic in this Framework :)
angularjs + XSLT in Umbraco
Hi,
I'm trying to get the AngularJS to work together with XSLT, but having issues with such a simple thing as showing a hello world instead of {{data binding}}.
Is it even possible to get AngularJS to work with XSLT?
Here is the super simple example:
Hope someone can help me getting up running basic on the AngularJS + XSLT :)
Thanks a million,
Niels
Niels,
In xslt the curly brackets have meaning so lets say you want to set an attribute on an element you can do it as
or
So I guess in your xslt you would need to encode the curly brakcet.
Regards
Ismail
Hi Niels,
There shouldn't really be a lot of hurdles to overcome - what one needs to remember is that there's a couple of things you need to think of when generating the output:
<script>
or<div>
tags in the outputYou do that at the top of the file:
so to generate this:
Do this in XSLT:
Hope that gets you going - otherwise shout! :-)
/Chriztian
Hey,
or simply {{{{data.binding}}}} wich escapes the curly braces :-)
{{ = { in XSLT!
But Ismail's solution by using the <xsl:attribute /> stuff would work as well.
Hi everybody,
Tried to get this to work, but no succes :S
The {{{{data.binding}}}} didn't do the trick.
I have now made it even less fancy, with the following example:
Could I ask for help on getting the above to work, if so - I think I'm ready for the beautiful world of AngularJS - I hope :)
Niels
Hi Niels,
It's only when used inside of an attribute that you need to escape the curlies - I didn't make that obvious enough, I see.
(So this one only needs the regular set of double-curlies to work - the previous probably failed because of the critical angular.js
<script>
tag being closed as<script />
which is known to fail in atleast a couple of browsers...)EDIT: Oh, and you obviously need to run this from a webserver, because of the use of the protocol-less URL (//) for the AngularJS file...
/Chriztian
Hi Chriztian,
I found the issue has nothing to do with AngularJS and XSLT at all, but the order of AngularJS and jQuery. I was calling jQuery at first and thereafter AngularJS. When I changed the order of these everything worked just fine.
Thanks to all the help you, Mads and Ismail provided.
Looking so forward to work with AngularJS. Per has really sold the idea of the magic in this Framework :)
Kind regards,
Niels
is working on a reply...