- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2016 01:29 AM
Hi,
I'm new to the Service Portal and tried to customize the Header Menu.
After some research I found out that there is currently a problem with cloning the Header Menu.
I'm aware of the issue with the spDropdownTree directive and tried to create my own angular provider directive in the service portal as mentioned on https://github.com/service-portal/documentation/issues/50.
So far I created the following angular provider directive:
Type: Directive
Name: spDropdownCustom
/*! RESOURCE: /scripts/app.$sp/directive.spDropdownTree.js */
/* */
angular.module('sn.$sp').directive('spDropdownCustom', function () {
return {
restrict: 'E',
scope: {items: '='},
replace: true,
template: '<ul class="dropdown-menu">' +
'<li ng-repeat="mi in items" style="min-width: 20em;" ng-class="{\'dropdown-submenu\': mi.type == \'menu\', \'dropdown-menu-line\':$index < items.length - 1}" ng-include="getURL()">' +
'</ul>',
link : function(scope, element, attrs, controller) {
scope.getURL = function() {
return 'spDropdownTreeTemplate_custom';
}
}
}
});
After that, I changed the directive call in the menuTemplate and spDropdownTreeTemplate_custom from <sp-dropdown-tree to <-sp-dropdown-custom.
The templates are available on your instance under https://yourservicenowinstance.service-now.com/sp_ng_template_list.do?sysparm_query=&sysparm_first_r...
But my scripted list (OOTB Request Menu Entry) wont want to show the dropdown menu as seen in the following picture:
Does anyone know if my angular provider directive is correct or knows how I can get my dropdown to work again?
Maybe nathanfirth?
Solved! Go to Solution.
- 12,153 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2016 01:52 AM
Okay so apparently I'm also new to angularjs and just found the article from Nathan about how to create an angular directive in service portal.
I removed the code "angular.module('sn.$sp').directive('spDropdownCustom'," and the corresponding bracket from the angular provider directive and the dropdown works fine again.
The final code of my directive is now:
- /*! RESOURCE: /scripts/app.$sp/directive.spDropdownTree.js */
- function () {
- return {
- restrict: 'E',
- scope: {items: '='},
- replace: true,
- template: '<ul class="dropdown-menu">' +
- '<li ng-repeat="mi in items" style="min-width: 20em;" ng-class="{\'dropdown-submenu\': mi.type == \'menu\', \'dropdown-menu-line\':$index < items.length - 1}" ng-include="getURL()">' +
- '</ul>',
- link : function(scope, element, attrs, controller) {
- scope.getURL = function() {
- return 'spDropdownTreeTemplate_custom';
- }
- }
- }
- };
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2018 05:41 PM
I made a summary post on how to do this here: Clone the Header Widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2019 11:05 PM
Hi ,
This article was very helpful. I still have a problem where the Level 2 menu is not showing up. it shows the carrot down, but on click it doesn't work. Do you have any solution for this?
Regards,
Yogi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2020 08:28 AM
This was a life saver! Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2020 09:48 AM
Hi mkaufman,
I followed the blog and made the custom header, but I see an issue with menu items on the header not showing the dropdown. Am I missing anything in the angular directive? do you have any resolution for this? any help would be appreciated!
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2018 05:19 PM
This should be raised as a defect with HI because SN has on purpose used an "internal" widget to build the header, thus breaking their own concept of "cloning" widgets.