Run external javascript script from angular component.html - angular8

https://paymentgateway.interswitchgroup.com/paymentgateway/public/js/webpay.js'
data-isw-trans-amount='10000'
data-isw-customer-ref='1581329633259'
data-isw-customer-callback='customCallback' defer>
This block of code is given to me by my payment gateway. it works perfectly on a plain html file.
I added this block to my angular component.html but the script tag is removed by angular. how can i solve this. thanks

Related

Import custom component as script Vue JS

I'm currently trying to use a custom component (https://github.com/wolfika/vue-playing-card) in my demo application built with Vue CLI.
First I've tried in a JS Fiddle (https://jsfiddle.net/xwb59m8g/1/) and everything works as expected just by importing the <script> (as explained in the Github "Browser" section) and using the <vue-playing-card> custom component. Than I've tried including the component in my Vue CLI app by following the instruction on the Github page under the "Bundler (Webpack, Rollup)" section and everything works.
My problem is that, for some reasons that I will explain if you need to know, I have to include this component using the <script> tag, as in the JS Fiddle, and not with the "Bundler (Webpack, Rollup)".
I tried including the <script> tag at the bottom of my index.html file but when I try to include the custom component in my Vue application this error gets printed in the console:
Unknown custom element: - did you register the component correctly? etc.
I really don't understand what it's happening since in the JS Fiddle everthing works as expected... can you help me? Thanks in advance and sorry if this is a stupid question, but I've tried and searched all I could.

Unable to inject javascript with Swashbuckle/Swagger

I'm using the Swashbuckle NuGet package to create Swagger documentation for my API. https://www.nuget.org/packages/Swashbuckle
I'm trying to make some minor changes to the UI - essentially just to add some corporate branding to the header.
I have added two files as embedded resources to my project, in a directory called resources.
These are injected into the UI via:
.EnableSwaggerUi(c =>
{
c.InjectStylesheet(thisAssembly, typeof(SwaggerConfig).Namespace + ".Resources.Swagger.css");
c.InjectJavaScript(thisAssembly, typeof(SwaggerConfig).Namespace + ".Resources.Swagger.js");
}
Which results in the following link being added to rendered page.
<link href="ext/ang_nav_api-Resources-Swagger-css" rel="stylesheet" type="text/css" media="screen">
This is all correct and the stylesheet works as expected.
However the .js script doesn't appear on the client.
Changing the c.InjectJavaScript to c.InjectStylesheet does inject the file as a <link> .. so I'm happy that the file itself is correctly embedded etc.
What could be wrong here?
The .js script will not appear on the client. (not on the way you would expect)
Look closely to the code of index.html:
https://github.com/domaindrivendev/Swashbuckle/blob/8223bedae706fec612c98ebbcee6b2d7033ae349/Swashbuckle.Core/SwaggerUi/CustomAssets/index.html#L98
Your customScripts will be loaded dynamically on the onComplete event
$.getScript(script);

I am learning bootstrap 3 and I am not getting where to place jquery codes

I tried to put it in script and without script tag.Suppose we have to run following code.What should we do?I have included proper bootstrap css and js files.
$('#myModal').modal('toggle')
Is it possible that the script is running before DOM ready? Try
$(function(){
$('#myModal').modal('toggle')
});
Other than that, either jQuery or bootstrap js file might not be included properly.

How can you include a javascript files from a CDN in Jasmine?

When using Jasmine in a Rails project, to keep the dependencies consistent in my Jasmine specs, I want to pull jquery from a cdn as is done on the real page. I try to do that like so, in my Jasmine.yml file:
helpers:
- http://code.jquery.com/jquery-1.9.1.js
However, this never works, as when viewing the source of the localhost:8888 I get:
<script src="/__spec__/http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
How do you this correctly?
as answered in https://github.com/pivotal/jasmine-gem/issues/135
I wrote a helper to load external javascripts. It's not the best solution (i would prefer config file use) but it works for me.
var head = document.getElementsByTagName('head')[0];
var jQueryScript = document.createElement('script');
jQueryScript.setAttribute('type', 'text/javascript');
jQueryScript.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');
head.appendChild(jQueryScript);
#emrox's answer is correct and works for jasmine 2.0.
However in jasmine 2.1.3 it doesn't. This is due to the fact that when the tests are run(i'm using Chutzpah) "http:" isn't pre-pended to the CDN reference. It is in version 2.0 of jasmine.
The fix I implemented that worked involved the following line of code:
jQueryScript.setAttribute('src',
'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js');
Hopefully this helps someone before they decide to downgrade to 2.0!
Issue 135 made it so you can list CDN entries in your jasmine.yml file. e.g.
src_files:
- http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js
- http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js
- lib/javascript/**/*.js

Google Extensions API 2

I have a problem. I had a app on the manifest v1.
But now it tells me to change it to v2. But it gives me an error like:
Refused to execute inline script because it violates the following
Content Security Policy directive: "script-src 'self'
chrome-extension-resource:".
I tried to change in the manifest:
"web_accessible_resources": [
"jquery-1.7.1.min.js",
"plugin.js"
]
But in the html code, I have:
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script src="plugin.js"></script>
How do I put it now? Should I delete that? If i delete it won't run! My popup doesn't even opens anymore :|
Hope you understood my problem, thanks
(I'll thank more if someone gave an example of API v2 using javaScript to download :) )
This error usually means that there is some script being executed directly inside your HTML page, not included via an external javascript file.
For example:
<script type="text/javascript">alert('hello');</script> embedded inside your html file is an inline script. The correct way to do it would be
<script type="text/javascript" src="hello.js"></script> .
Your file hello.js would include alert('hello');
I hope this helps.