Differences between Angular.js and Angular.dart?

CorayThan picture CorayThan · Nov 15, 2013 · Viewed 31.4k times · Source

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?

Answer

James deBoer picture James deBoer · Dec 10, 2013

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.