top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between component and controller in angular.js?

0 votes
704 views
What is the difference between component and controller in angular.js?
posted Dec 18, 2017 by Manish Tiwari

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Component
In AngularJS, a Component is a special kind of directive that uses a simpler configuration which is suitable for a component-based application structure.

This makes it easier to write an app in a way that's similar to using Web Components or using the new Angular's style of application architecture.

Advantages of Components:
- Simpler configuration than plain directives
- Promote sane defaults and best practices
- Optimized for component-based architecture
-Writing component directives will make it easier to upgrade to Angular

Controller
In AngularJS, a Controller is defined by a JavaScript constructor function that is used to augment the AngularJS Scope.

Controllers can be attached to the DOM in different ways. For each of them, AngularJS will instantiate a new Controller object, using the specified Controller's constructor function:

the ngController directive. A new child scope will be created and made available as an injectable parameter to the Controller's constructor function as $scope.

answer Apr 30, 2018 by Kuldeep Apte
...