How we can use Angular JS in UI page in San Diego release?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 01:35 AM
Please let me know how we can use Angular JS in UI page in San Diego release?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 01:52 AM
Hi
please find the solution at https://community.servicenow.com/community?id=community_article&sys_id=f8c9d98c1b521850305fea89bd4bc...
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2022 02:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 09:06 PM
Hi Maik,
Please advise for the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2022 05:16 AM - edited 10-25-2022 05:20 AM
I also ran into an issue with using angular in a UI page after the San Diego upgrade and enabling the Next UI/Polaris theme. I was able to get something working that I thought I would share. I'm hoping the experts will be able to provide a better solution.
UI Page HTML: (Removed the angular template)
<html>
<!-- necessary for pages that do not contain angular yet:
<sript src="/scripts/angular_includes_no_min.1.5.11.js"></sript>-->
<!-- The HTML tag that will contain the inserted code -->
<div id="angular-app"></div>
</html>
UI Page Client Script: (Added template to script instead. Also added an ng-if to example.)
var angularApp = angular.module('myApp', []);
angularApp.controller('angularController', function($scope) {
$scope.name = 'Blue';
});
var appElement = angular.element('#angular-app');
var html_template = "<div ng-controller=\"angularController\">Type a color: <input ng-model=\"name\"/><div ng-if=\"name=='Blue'\"><h2 style=\"color: {{name}}\">You entered: {{name}}</div></h2></div>";
var escapedText = html_template.replace(/^\s*\/\/\s*\/\*\s*|\s*\*\/\s*\/\/\s*$/g, "").replace(/</g, "<").replace(/>/g, ">");
var app = angular.element(escapedText);
angular.bootstrap(app, ['myApp']);
appElement.append(app);
This seems to work on my end, but I'm sure there is a better way of doing this.