How to link an HTML file using Angular.js with a controller?

I am trying to create an application module using the MEAN stack and I am using MVC. So, I have a folder called AppModules, and inside it there is a folder called search and inside it, I have 3 folders, models, views and controllers. I wrote an HTML file in the views folder. In addition, in the controllers folder, I have a simple function that simply outputs something to the console. Now, how can I tie them together?

I looked at the MEAN glass tutorial, and the person in the video wrote the HTML file in the index.html file of the project, and this is what the server automatically opens. I am working on this project with other people, therefore, to avoid conflicts, none of us writes in the index.html file. We divide our tasks into modules, and each person has his own module. So, how can I let the HTML file that I wrote open without copying all the code in index.html and how to link it to the controller in the controllers folder?

In the video I saw, the index.html file included something like this: (changed to my own file names)

<script src = "../AppModules/search/controllers/SearchBoxController.js"></script>

But when I try to use this, I just get an error message in chrome saying that the file was not found, although this should be the correct path. Is what I'm doing even remotely correct, or is there an easier way?

EDIT : I accidentally inserted the HTML tag that I used when I tested. An edited post with an HTML tag that I had to write at the beginning. Still not working. Even when I copy my code to index.html and change the path to src, I still can't get it to work.

Directory structure:

enter image description here

+4
source share
2 answers

, . controller/SearchBoxController.js ./controller/SearchBoxController.js

+1

script src: index.html , . index.html , ? , .

+1

All Articles