Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart's Web Component vs Angular's Directive

Dart's Web Component and Angular's Directives look like they serve very similar purposes. Are there any significant differences?

like image 319
John Tseng Avatar asked Jul 06 '13 18:07

John Tseng


People also ask

What is the difference between a component and a directive?

The Component is used to break up the application into smaller components. That is why components are widely used in later versions of Angular to make things easy and build a total component-based model. The Directive is used to design reusable components, which are more behavior-oriented.

Can a component be directive in Angular?

Yes, in Angular 2, Components are a type of Directive. According to the Doc, “Angular components are a subset of directives. Unlike directives, components always have a template and only one component can be instantiated per an element in a template.”

What is a directive in HTML?

What are Directives? At a high level, directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS's HTML compiler ( $compile ) to attach a specified behavior to that DOM element (e.g. via event listeners), or even to transform the DOM element and its children.


1 Answers

They serve similar purposes indeed. However Web Components are not a part of Dart, they are a part of browsers. Dart Web-UI does use Web Components (http://www.w3.org/TR/2013/WD-components-intro-20130606/). AngularJS has plans to use them for 2.0 as can be read here: http://www.2ality.com/2013/05/web-components-angular-ember.html

What it comes down to is that a lot of the functionality is shared. But Angular.js has a pure JS implementation and Darts' Web-UI uses browser techniques.

Angular will use the underlying web platform features available to it 
(e.g. Node.bind, template integration, Custom Elements, etc...)
like image 183
bbs Avatar answered Sep 23 '22 18:09

bbs