Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between Angular.js and Angular.dart? [closed]

I know a bit about Angular.js, but I want to teach myself Dart and Angular.dart now. I'm a bit curious what the differences between the two are, though. The Angular.dart tutorial specifically says it won't compare the two. Does anyone who has used both have a perspective on what the differences are?

like image 713
CorayThan Avatar asked Nov 15 '13 04:11

CorayThan


People also ask

Is Dart similar to angular?

AngularDart is somewhat similar to AngularJS but it differs in implementation, takes advantage of dart features such as classes and annotation. Google Team has come up with a Dart version of AngularJs framework, which is also known as AngularDart.

What is angular Dart?

AngularDart: AngularDart is a framework developed by Google for building web applications, server applications, or single-page applications using HTML, CSS, and Dart. It is commonly known for its good speed, execution, and productivity.


3 Answers

Update #2 (Aug '16) A Dart version of Angular is now maintained by the Dart team on Github: dart/angular2 on github

Update: The AngularDart project is mothballed and has been superseded by Angular2. Angular2 is the most recent iteration of Angular and works in Dart.

The original answer below compares AngularDart and AngularJS 1.x.

AngularDart and AngularJS are both maintained by the Angular team. We've taken a lot of knowledge from the JS side and applied it to Dart. We have also taken a lot of code and ported it straight to the Dart world.

At a technical level, in the core of Angular:

  • The expression language is compatible between the two versions. The AngularDart parser started as a straight port from JS but has been evolving on its own. A big difference there is that the Dart parser supports multiple backends, including a Dart code generator.

  • The DI system is different. In Dart it is class based where in Javascript it is symbol based.

  • The compiler has been completely rewritten in the Dart version. This means that directives behave differently and now there is a distinction between "structural directives" which modify the DOM, "decorative directives" and components.

  • ng-transclude has "melted into the browser", replaced by the standard shadow DOM.

  • directive controllers have been merged into components

  • directives in AngularDart are declared with an annotated class. link / compile functions are replaced with an apply function

  • In AngularDart, the scope is digested automatically through Dart zones, eliminated the need from scope.$apply.

  • AngularDart has a concept of attribute maps which hasn't made it back to AngularJS yet. This means that directives should need many fewer scope.$watches or even a dependency on the Scope.

There may be other differences, but that is a good list to get you started.

like image 157
James deBoer Avatar answered Nov 23 '22 17:11

James deBoer


So the first difference is pretty obvious: AngularJS is written in JavaScript whereas Angular.dart is written in dart.

While Angular.dart follows the core principles of AngularJS it seems to be a bit of a playground for new features to evolve. I guess the core team takes all the learnings from AngularJS and tries to implement things just slightly better for the Angular.dart version. Currently it seems as if a bunch of things are first implemented in the dart version of Angular before they get backported to AngularJS. For instance they just added a more lightweight version of ng-repeat which eventually should end up in AngularJS.

Also the Angular team recently shared some insights on what's planned for Angular 2.0. I bet most of those things will first land in Angular.dart before they land in AngularJS.

like image 41
Christoph Avatar answered Nov 23 '22 15:11

Christoph


Update 01/2018

See also What's the difference between Angular 2 TS and Angular 2 Dart?

Update 08/2016

Angular 2 for JS and Dart are now independent projects and will diverge to some degree.

For example the NgModule introduced in TS RC.5 will probably not land in Dart and also the router module will probably not be translated directly. These are changes that were necessary in TS for lazy loading. Dart has an easier lazy loading story and doesn't need many of the changes introduced in Angular2 for TS.

Update

With Angular 2 there are (almost) no differences anymore because Angular.dart and Angular.js are auto-generated from the same TypeScript source. http://techcrunch.com/2015/03/05/microsoft-and-google-collaborate-on-typescript-hell-has-not-frozen-over-yet/

Original

  • Analog of ngTransclude in Angular.Dart
    Angular.dart uses shadowDom while AngularJs doesn't.
    AngularJs uses ngTransclude instead.

  • What is the difference between ng-app and data-ng-app?
    Angular.dart seems not to support other prefixes like discussed in the linked question.

  • Angular.dart has no equivalent to ng-init. (see also GitHub issue - port: ng-init)

  • Angular.dart has no ng-controller directive (port: ngController)
    instead @NgController(selector:'[foo-controller]', publishAs:'foo') is used

  • Angular.dart doesn't support ng-repeat with maps (ng-repeat with a Map not working)

  • Angular.dart has no restrict Has Angular.dart directive an equivalent to AngularJS's `restrict`

  • Misko Hevery the creator of AngularJS and member of the AngularDart team answered a similar question here

This article lists several differences: ANGULARDART FOR ANGULARJS DEVELOPERS. INTRODUCTION TO THE BEST ANGULAR YET.

like image 21
14 revs Avatar answered Nov 23 '22 16:11

14 revs