Quantcast
Viewing all articles
Browse latest Browse all 4826

How do add attributes to window in Ember

@SarathSantoshDamaraj wrote:

#1

I am using a plugin Dayjs, and want to be available like MomentJs in window scope – window.moment. I am manually adding it to window from a utils file.

//.../utils/dayjs.js
import dayjs from 'dayjs'
...
window.dayjs = dayjs;
...

Is there any better way to do the same from ember perspective ?

#2

and I also at some point in one of component.js files, appending script tag to the document.head. Considering the script content is from the same domain and secure.

//.../someComponent/component.js
...
appendScript() {
      var script = document.createElement('script');
      script.type = 'text/javascript';
      script.text = locale.content;
      script.text += `dayjs.locale('${locale}')`;
      document.head.appendChild(script);
}

Is there any other approach to accomplish this too ?

-TIA

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles