- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2015 11:58 AM
Has anyone successfully used routing within an Angular UI? I'm working with a BootStrap navbar, and trying to define content using routing (ng_route). Having a little trouble, but before I spend too much time with this approach, wanted to checkin to see if this is even possible within ServiceNow.
Thanks in advance for any advice/direction!
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2015 07:36 AM
Hi Mitch,
It is definitely possible. The best approach I have found is to use a processor to handle the views because UI Pages and other endpoints add text to any template you would send through. So your ng-route when statement will point the templateUrl to the processor. The processor will then return the view html template. Please feel free to ask any questions on this.
Kind regards,
Travis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2016 09:57 AM
Hi Greg,
A UI Macro does not have a URL endpoint so Angular JS is basically pointing at nothing when you use templateURL. You could use a UI Page with the Direct field checked and that should give you the desired result. Alternatively you can use a Processor to retrieve specified html and point the URL at the processor endpoint (I used this approach previously with a custom Angular Template table).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2016 10:37 AM
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2017 12:55 PM
It's actually preferable to implement with templates as UI Macros as you don't want a bunch of user navigatable URLs for your templates (as a UI Page is). Luckily servicenow already provides a processor for help in handling this. So you use a UI Macro for your template and then your URL would be "angular.do?sysparm_type=get_partial&name=NAME_OF_UI_MACRO_HERE". Now you have lightweight UI Macros which aren't end-user accessible URLs like UI Pages, but your angular app can still reach them.
On a related topic however, has anyone figured out a way to use script tags to include a UI Macro as a template in a UI Page? So if I had a UI Macro called "my_ng_template" you could then include it in a UI Page similar to the following:
<script>
<g:macro_invoke macro="my_ng_template" />
</script>
When you actually do this and load the page the macro_invoke portion does not work when put inside of a script tag.