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

Getting Started with AngularJS in ServiceNow

Rick Mann
Tera Expert

At the K14 conference I heard of a few customers starting to use AngularJS within ServiceNow, so I started doing some reading on Angular.   Are there any good articles, tips/tricks for getting started with AngularJS in ServiceNow?  

 

Thanks

 

Rick

41 REPLIES 41

Hey Greg - I'm hardly an Angular guru, but I do know a few ServiceNow tricks. That syntax checker runs without regard for the fact that we're using Angular, and so it tries to save us from typical 'non-Angular' issues. Usually good; in this case, a nuisance.



The good thing is that the syntax checker runs client-side and only on the form view. To get around it, try this:


  1. Complete your code either on the form view or in another syntax editor. Copy it to your clipboard.
  2. In SN, add the 'HTML' field to the listview for your UI Page list.
  3. For your specific UI Page, double click the 'HTML' field from the listview.
  4. Paste in your contents and click the green check-mark to save.
  5. Now, click to open the formview of your UI Page - it should contain your code as desired!

Thanks for the quick reply Ben. Yeah, I learned that trick from you earlier, but when I still put the URL in for my UI Page, the result is below. I will keep digging. Thanks!




Error during script processing



Attribute name "dhx-scheduler" associated with an element type "div" must be followed by the ' = ' character.



line: 2130, column: 35



<div data="events" dhx-scheduler style="height:600px; width:800px;">


Hey Greg - Are you able to call the directive directly without the need for the div tags? ie:



<dhx-scheduler data="events" style="height:600px; width:800px"> </dhx-scheduler>



I haven't actually tried this (and, again, not a Angular guru), but I've seen the syntax used...


try doing this with the div:



<div data="events" dhx-scheduler="" style="height:600px; width:800px;">




Since the macro is xml based xml is strict. It won't allow the attribute of an element not to have a value. It's expecting every attribute to be followed by an equals sign.


But yes creating a directive for dhx-shceduler would be better since you're using Angular