I am so confused about this. All I want to do is simply break up my javascript into modules, and include them in certain pages. Some pages may need my user-module.js , some pages may not.
I have Googled, read the tutorials, and it's still not working for me.
Here is a simple test case:
1. Include my script from my html
<script src="../js/login-view-model.js"></script>
Now, inside there...
2. TRY to include another module/js file
// LoginViewModel
// I NEED MY IMPORT HERE
import { userService } from '../js/viewModels/user-service.js'
var LoginViewModel = function () {
self = this;
userService.user.sayHello();
}; // End View Model
ko.applyBindings(new LoginViewModel());
Now, inside my user-service.js
user-service.js
let user = {
sayHello: function() { alert("hello") };
}
export {user};
I don't see what I am missing.
Do I need to use another JS library to get this simple example working? I am so lost...lol , please help!
Oh, as you can see I am using KnockoutJS. Not sure if that is the problem.
Thank you.
John