Question

I'm new on angluarjs and trying to build an example-application.

This application is divided into 3 parts/sections:

A.) map

B.) "received"-area

C.) "send"-area

Every section has its own layout/view-area, not visible at the same time.

In part B.) you can load information from server by click or automatically, which will be displayed in part "B.)" as text and in section "A.)" as map-marker.

Additionally you can click inside section "A.)" to set a new marker.

In section "C.)" there is a send button to take the new marker from "A.)" in order to send this to the server.

Currently: all of the sections (A,B,C) are angular modules/own apps.

But I don't know, if that is the right way/best practice.

An other way could be a single module for the whole page an 3 controllers (A,B,C) which handle the logic for sections A,B and C.

What is the right way in angularjs?

Was it helpful?

Solution 2

After searching the way to get some inspiration, i decided to realize the following think:

For all the self-made code, I use one module for the whole application and for all the external things, bundled with external plugins and services, I take a different module. This means: pne module for each "service-plugin bundle" (like google API & angular-google-maps plugin)

So I can switch the module, if the external service does not work, etc.

Looking at my example in the question this means:

Application part A: the map and all the map-specific things (set new marker, draw circle, etc) are insight a map-module. If I decide to use open street map instead of google maps i will plug in an new maps module

Application part A and B: this is my "main" app module with different controllers.

OTHER TIPS

From your description, I recommend designing it as a single AngularJS app with separate controllers for each view. It sounds like you would benefit from using an angular service to handle the client-side business logic and cache any shared data/models that could be used by the views. It is a best-practice in Angular to keep the controllers pretty lean and focused just on the view setup/binding and orchestrating the access to the services.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top