<now-attachments-list template="sp attachment" />

MCH
Mega Contributor

Hello,

I used the widget 'Ticket Attachments' in Service Portal of Helsinki.

In this widget there is an element which call 'now-attachments-list'.

I want to understand what the meaning of this element, maybe it's a directive of angular? so, where it's defined?

I would be happy if someone can explain me what is it exactly.

thanks,

Michal

1 ACCEPTED SOLUTION

Michal,



I apologize that my answer was not clear. When I stated that it was on the ServiceNow side, I meant that it's not directly accessible to us. It's directly accessible to ServiceNow employees on their side. You won't find it under any Module, Angular Providers or dependency sections.


That said, it doesn't mean you can't get to it. With a closer look by doing an Inspection, you can see how the directive is defined.



Here is the directive script:



angular.module('sn.common.attachments').directive('nowAttachmentsList', function(getTemplateUrl) {


  'use strict';


  return {


  restrict: 'E',


  replace: true,


  templateUrl: getTemplateUrl("attachments_list.xml"),


  link: function(scope, elem, attrs, $parse) {


  scope.icons = {


  preview: attrs.previewIcon,


  edit: attrs.editIcon,


  delete: attrs.deleteIcon,


  ok: attrs.okIcon,


  cancel: attrs.cancelIcon


  };


  scope.listClass = "list-group";


  var inline = scope.$eval(attrs.inline);


  if (inline)


  scope.listClass = "list-inline";


  scope.entryTemplate = getTemplateUrl(attrs.template || "attachment");


  }


  };


});


;


View solution in original post

28 REPLIES 28

MCH
Mega Contributor

Hi Chris,


Thank you so much !


I was sure that the directives are defined in somewhere...and didn't think on the option that they are not available for us.


Thank you so much


Good luck !




Michal,



You're welcome. Glad I could help.


MCH
Mega Contributor

Hi Chris,



I have another question regarding this directive:


As you can see, the template of the directive ( HTML) isn't in the code below.


  1.   templateUrl: getTemplateUrl("attachments_list.xml"),  

So, do you know where I could find it?



I have another directive   "spModel" that I want to find his HTML, but the template not write in the directive but also in XML.


I want to know how I could find his HTML?


This is the directive:


/*! RESOURCE: /scripts/app.$sp/directive.spModel.js */


                      angular.module('sn.$sp').directive('spModel', function($timeout, spUtil, glideFormFactory, glideUserSession, catalogItemFactory, glideFormEnvironmentFactory, catalogGlideFormFactory, spUIActionFactory, glideModalFactory, $uibModal, glideListFactory) {


                              'use strict';


                              return {


                                      restrict: 'E',


                                      templateUrl: 'sp_model.xml',


                                      replace: true,


                                      scope: {


                                              formModel: "=",


                                              mandatory: '=',


                                              isInlineForm: '=?'


                                      },


                                      controller: function($element, $scope) {


                                        ---


                                        etc...



Thanks !


Michal.


Hi Michal,



For the sp_model.xml, that can be captured by navigating to the sp portal and doing an inspection as well. Within the element inspection section do a "find" for "ng-template" and you'll see a few of the templates used. Or just do a find exactly for what you want, in this case sp_model.xml, and click the dropdown arrow beside it and you'll see the template markup.



find_ng-templates.png



Unfortunately, attachments_list.xml looks like it is handled by a processor through the angular.do? path. That's only a guess on my part though.


So, is there any other way to get attachments template?
I suppose it will work if we provide our custom template ie. <now-attachments-list template="my_template"/>