javascript - Inject custom JS file in ionic project -
i'm new ionic/angularjs. need display image carousel in single view, need load in view corresponding js (carousel.js). don't want put js file index.html file, cause loaded in pages , need use in particular one.
my question how can load js in particular view?
thanks in advance
add following code in onload of page want load js file
<template onload="onload()"></template> function onload(){ var script = document.createelement("script"); script.src = "https://somejavascript file url"; document.getelementsbytagname("head")[0].appendchild(script); }
it called when particular page or template loaded.
regards.
Comments
Post a Comment