The CreatorCon Call for Content is officially open! Get started here.

AngularJS Routing Question

mitchellhenry
Tera Contributor

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!

1 ACCEPTED SOLUTION

tltoulson
Kilo Sage

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


View solution in original post

12 REPLIES 12

tltoulson
Kilo Sage

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


Thanks Travis...I'll work on that approach this afternoon.   Are there CORS issues to address, that you have found?   I saw a post somewhere yesterday (can't find it now) that referenced using localhost somewhere in the config.   I'm working in a developer instance at the moment.


I have not found any CORS issues but I have never used anything regarding localhost, except when running an AngularJS site locally and not on the ServiceNow platform.   When using it on the ServiceNow platform, all my URL's pointed to the same origin, my ServiceNow instance URL.


Let me present a conceptual question...


I'm starting with a NavBar that basically presents 3 different process paths related to access management (request, status, and administration) from the application dashboard.   For design logic, it makes sense to me to split these out with separate controllers, etc.  


So my question is: Is routing the best approach or do you think I'd be better served using UI Macros for the separate UI pages (paths)?   Or is there something else to consider?