skip to Main Content

i have a screen file let say screenA.blade.php. inside this file, i want call a constant file that store some of string let say constant.js.

is this possible?

this is what i have inside screenA.blade.php

<head>
      <script>
              ...
              // some of js code here
              // want call string from constant.js here
              // console.log(string from constant.js)
              ...
      <script>
<head>

2

Answers


  1. Once you’ve inserted the script tag for constant.js, then you’re able to use the variable defined in the constant.js file.

    An example for screenA.blade.php might look like the below code snippet:

    <head>
      // path to constant.js file
      <script type="text/javascript" src="constant.js"></script>
      
      <script type="text/javascript">
      
        // Put javascript code here.
    
        // Try calling the string defined in constant.js here
    
        // Using console.log( string from constant.js )
    
      </script>
    
    </head>
    
    Login or Signup to reply.
  2. Yes you can, put the file constant.js inside in file screenA.blade.php

    //constant.js
    
    //will printed on console
    console.log("blablabla")
    
    //will printed on blade file
    document.write("blablabla")
    <!-- screenA.blade.php -->
    <head>
    
    </head>
    
    <body>
      <script src="constant.js"></script>
    </body>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search