简体   繁体   中英

Error loading external javascript files in jade layout in Angularjs

I'm new at Angularjs and just want to load some external js files to work in my app (they're big so I don't want to put them directly into the controller).

I tried to use

ng-include(src='javascripts/javascriptfile.js')

But I get these error messages

Error: Syntax Error: Token 'js' is an unexpected token at column 28 of the expression [javascripts/javascriptfile.js] starting at [js].

TypeError: undefined is not a function

The problem is, it works when I was using these files in express with no error messages, so I know it's not the javascript file, and when I try to use things like

(script src= 'javascripts/javascriptfile.js')

without the ng-include, nothing executes.

ng-include is for including HTML template partials, not javascript.

You should use the <script> tag to include javascript files.

Try:

script(src='javascripts/javascriptfile.js')

instead of:

(script src= 'javascripts/javascriptfile.js')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM