What is the meaning of angular controllers, is it possible to execute a controller task by directive?

Starting with the angular developer.

Let me start by saying that I really admire angular, I think this is a very well-designed infrastructure.

However, I cannot understand why the controllers exist. Let me explain:

From what I understand, services have a clearly defined role: 1) store parts of the model needed throughout the application 2) execute business logic 3) talk with the server

Views: 1) display model

Directives: 1) create areas 2) disclose functionality for the areas they create through which they take input from the user and a) change the model b) manipulate the DOM

What is the meaning of controllers? The directives seem to be designed to do all the work that controllers do.

Is the definition that the controller should manipulate the model and the directive controls the DOM?

+4
source share
2 answers

Angular is not a particularly stubborn structure, although some people may tell you that it is.

Controllers are an easy way to access / create an area and link to many other parts. They are flexible and lightweight and well suited to “the thing in which you just need to do something in this place”

, ", , ajax", 5 . .

, , , , , , .

, , , .

+2

AngularJS:

:

?

DOM ( , , CSS), HTML (HTML) AngularJS, DOM DOM .

:

:

  • $scope.

  • $scope.

:

  • DOM - -. . Angular , DOM.

  • - Angular.

  • . Angular.

  • . Angular.

  • (, ).

, .

, , AngularJS Html- js- ( -), "", , , , DOM, , . , : .

MVC , . , -: , . , - .

, , : , UI -, , .

AngularJS .

, , alternative?

+1

All Articles