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?

3 answers

  • answered 2019-05-15 03:36 Tony Ngo

    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

  • answered 2019-05-15 03:57 Baldev Bhattarai

    .ts is just the file extension which represents typescript file. model-name.model.ts is the the common way of naming model. Similarly, component-name.component.ts is for component, component-name.component.html for view and service-name.service.ts for service. Finally, as the earlier comment says, you can't directly relate MVC with angular architecture.

  • answered 2019-05-15 04:47 Divneet

    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).