Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling controllers and services in subfolders #30

Open
SoldierCorp opened this issue Jun 9, 2016 · 6 comments
Open

Handling controllers and services in subfolders #30

SoldierCorp opened this issue Jun 9, 2016 · 6 comments

Comments

@SoldierCorp
Copy link

Hi!

In order to use this kind of app structure for angular

app.js
--- controllers
------ controller.js
--- services
------ service.js

The webpack configuration you have will work? Or if not, is there a way you can help me to do that?

Kind regards.

@stefek99
Copy link
Contributor

That is something I'm using in my project:

screen shot 2016-06-24 at 17 30 31

(should be simple enough)

@seoj
Copy link

seoj commented Jun 29, 2016

Hi @SoldierCorp
This is something I've done in some of my projects, but it requires the use of require() instead of ES6 import.

requireAll(require.context('./services', true, /\.js$/));

function requireAll(require) {
    require.keys().forEach(require);
}

What the above code does is it recursively looks through the directory "services" for all files ending with ".js" and require() it.

@tatmanblue
Copy link

tatmanblue commented Jun 6, 2017

EDIT: I fixed the error I posted originally but I am still have problems.

I tried following the example by stefek99, but some information must be missing. I created a folder under app called "spanText" and added a js file. I then referenced it in app.js. My js file is a copy of the app.js file in the git repository. I renamed app to spanText and the directive to . I copied the html template etc.... However, my custom directive is never getting rendered. Its an empty tag in the dom.

What is missing?

@surfjedi
Copy link

surfjedi commented Jun 7, 2017

here is a bigger project that I just needed to upgrade to unit tests and used the great config from this repo. Thanks!
https://github.com/berzerk-interactive/angular-1.6.x-webpack-components-material-es6

@tatmanblue
Copy link

@surfjedi maybe you can help me fill in the blanks. when I run the code from the github repo you posted, all I see in browser is a directory listing of the generated js files. I do not see any of the "angular stuff" kicking in at all, definitely not seeing what is designed in index.html

@surfjedi
Copy link

surfjedi commented Jun 8, 2017

app
@tatmanblue that is what you should see.

I fixed a missing dep in package.json earlier today. Sorry - pull again. Then make sure you "npm install" then "npm run dev".

there is minor bug in lazy loaded states due to code splitting im working on, and I'm adding tests FYI. Its a work in progress. But the folder structure you are looking is there and working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants