0

As we know , AngularJS follows MVC pattern(more correctly MV*) . We usually create different directories for each layer . eg ., controller JS will be "controllers" and view will be normally in "html" directory . (controllers will work with service classes to get the data from server . We use to place service request JS in "services" folder)

But , we usually don't have separate directory for "Model" classes . Can someone provide a simple example for "Model" directory structure.

JavaUser
  • 25,542
  • 46
  • 113
  • 139

4 Answers4

1

The Model The model is responsible for managing application data. It responds to the request from view and to the instructions from controller to update itself.

The View A presentation of data in a particular format, triggered by the controller's decision to present the data.

The Controller The controller responds to user input and performs interactions on the data model objects. The controller receives input, validates it, and then performs business operations that modify the state of the data model.

a busy cat

1

Working on an angularjs based project I structure the front end the following way:

|wwwroot
    |Js
      |signup
        |signupCtrl.js
        |signupSrvc.js
      |login
        |loginCtrl.js
        |loginSrvc.js
      |dashboard 
        |dashboardCtrl.js
        |dashboardSrvc.js
    |templates
      |signup.html
      |login.html
      |dashboard.html
    app.js
    run.js
    routes.js
    index.html 

Understanding that some people consider the model, the place "where you hold data returned by the http service using @angular/http", according to the post Angular2: MVC, MVVM or MV*?

Then maybe this previous structure may help you having an approach. Hope it helps!

eduardo92
  • 1,085
  • 6
  • 9
0

When we say modal in angularJS, we are talking about the data that is being transferred from html pages to controller. Now, in general there is no standard architecture design to create a modal folder inside.

Reason being, the JS are not strongly typed language so it was not a straightforward way to implement as we can now do in Angular using typescript (which is strongly typed).

If you want to create a modal directory, you can create a JS classes and accordingly use it inside controllers.But as I said before, it will be your own personal choice. Normally we don't create a modal js files in angularJS.

Shashank Vivek
  • 16,888
  • 8
  • 62
  • 104
0

Modal is nothing but data. Whatever we are assigning the values to a scope variable to render in the view(html) is modal. So no need of separate directory for that and also it not a recommended approach.

Vishnu
  • 11
  • 2