0

This should be straight forward, but I'm stuck.

I'm trying to include mobile-angular-ui in an angular-fullstack-generator project but I keep getting

Uncaught SyntaxError: Unexpected token <  mobile-angular-ui.min.js:1

I'm adding the following at the end of the body of the _index.html, and the network tab is returning the proper 200 response.

<script src="/node_modules/mobile-angular-ui/dist/js/mobile-angular-ui.min.js"></script>

If I use import in app.js like this

import mobileUi from '../../node_modules/mobile-angular-ui/dist/js/mobile-angular-ui.js';

Then I get the following error

Uncaught TypeError: Cannot read property 'documentElement' of undefined   mobile-angular-ui.js:2584 

Where am I going wrong, where am I supposed to include this?

Thanks!

Justin
  • 21
  • 1
  • 3

2 Answers2

0

Normally, with the angular-fullstack app from https://github.com/angular-fullstack/generator-angular-fullstack, you just have to write:

npm install --save mobile-angular-ui angular angular-route

And all the dependencies will automatically be built.

Wandrille
  • 6,267
  • 3
  • 20
  • 43
  • Thanks for answering Wandrille, that command is downloading the packages, but when I try to inject/import it, either I include it in the html (and get the Token error) or I import it in app.js and get the documentElement error. Once I run the npm install, I'm stuck... – Justin Sep 21 '16 at 01:56
  • So, i have installed a new project. I have also done npm install mobile-angular-ui. And i got the same error as you. I have no clue why, sorry. – Wandrille Sep 22 '16 at 08:22
0

In angular-fullstack, all front end libraries are handled/installed through bower and all back end libraries are handled through npm.

So if you want to use mobile-angular-ui, which is a front end library, you should try installing it like this.

bower install --save mobile-angular-ui angular angular-route

Then add the module dependency

mobile-angular-ui

in app.js of client side Then serve the project again. Now your dependency will be added automatically in your index.html file and you won't need to automatically include it in your index.html

Umair Farooq
  • 1,684
  • 2
  • 14
  • 25