Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the controller in Angular 7 as it follows mvc architecture

According to my knowledge angular follows mvc architecture as i can see in the components there is .ts file(model) and .html file(view) but where is the controller?


2 Answers

While using the Angular framework, it is necessary to understand a few basic terms which will constitue the application you create.

Component: A component is a resuable code, which is capable of performing a set of functions or providing a view based on certain inputs. These inputs are optional. The component may additionally emit events in order to inform its parent component of the changes which might have taken place due to a particular action such as a click.

I am not too Keen on using MVC notation but if we were to strictly choose,

the template would represent the View, class is the Controller & the Service (when it used to retrieve data) is the model.

Because Angular is a client side framework, the MVC pattern Angular follows may be called as MVVC (Model, View, View Controller).

like image 188
Divneet Avatar answered Jan 22 '26 17:01

Divneet


There is no such thing controller in angular.

It's only have component, view, model, services

  1. Component: Will play the role of the controller since it handle logic for the template

  2. Template: Will handle the role view to display the data

  3. Model: Entity model will play the role model in your app

  4. Services: To handle logic for you making http request or doing some side effect in your code

like image 43
Tony Ngo Avatar answered Jan 22 '26 15:01

Tony Ngo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!