9

I just upgraded to AngularDart 0.10, renamed my Ngcontrollers to Controller and I am very surprised to see that Controller is marked as deprecated by dart-editor. I have seen that Controller is supposed to disappear in AngularDart 1.0 [1] but why is it already deprecated? Am I supposed to use something else right now?

[1] http://blog.angulardart.org/2014/04/angulardart-0100-ostemad-teleportation.html

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Vincent
  • 430
  • 3
  • 13

1 Answers1

10

I haven't really understood this change myself but some information:

https://github.com/angular/angular.dart/issues/919

It seems there is only a top level controller left and otherwise component should be used. This makes also publishAs obsolete.

See also: https://github.com/angular/angular.dart/issues/413

Misko Heverys response about the reasoning behind the decision
(copied from https://github.com/angular/angular.dart/issues/919)

ng-controller have some weird semantics, and always felt like the odd man out. ng-controller is only useful outside of component, and nesting them has issues, so you usually have only one.

Removing it simplifies the world. The issue is that it makes hello world kinds of apps more complicated, but that will be solved by allowing the root of the app to have its own type and one would get best of all worlds.

The issue that everything has to be a component only feels like an issue if the cost of creating them is high. If you have light weight components with decorator-directives then you have all the tools you should need for building your app.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • Ok but an issue I see about components is, as they use shadow dom, they are not styled as the remaining of the page, correct? – Vincent Apr 23 '14 at 07:36
  • 2
    There is a root controller without a component and you can also take a look at https://github.com/angular/angular.dart/blob/1e5ecbc48351e292d1c167c97ca1150ce77ca479/lib/core/annotation_src.dart#L316 – Günter Zöchbauer Apr 23 '14 at 07:41
  • As for the styling: you can chose whether you want to style the component as the remaining page, or whether you want to use a component-specific styling. To apply the global CSS files set the attribute "applyAuthorStyles" of @NgComponent to true (i.e. @NgComponent(applyAuthorStyles: true, selector='..."). – Stephan Rauh Apr 24 '14 at 19:02
  • `applyAuthorStyles` is deprecated for a while and already gone in the current dev release as far as I know. – Günter Zöchbauer Apr 24 '14 at 20:50
  • Sad but true, applyAuthorStyles is going to be removed in Chrome 35. Are there any alternatives? You know, I want to create a GUI widget framework that can be customized by the user. With shadow DOM, but without applyAuthorStyles I'm the only one who can customize the look and feel of the widgets. I refuse to believe this to be true. What am I missing? – Stephan Rauh Apr 27 '14 at 21:30
  • 1
    There are several solutions/workarounds: The Angular team was working on a component without shadowDOM. I think it is already available in master named`Template`. There are CSS selectors that allow to reach into the shadowDOM see http://www.polymer-project.org/articles/styling-elements.html. This might not work as expected because the selectors have changed several times and Dartium doesn't yet support the most recent incarnation. Another approach (which I haven't tried yet) see :http://stackoverflow.com/questions/20890392 The user should be able to force/trick Angular to use other CSS files. – Günter Zöchbauer Apr 28 '14 at 06:02
  • @GünterZöchbauer Do you have an example how to use (declare) the root controller? – nobody May 13 '14 at 20:21
  • Seems this is not yet published. I saw: `applicationFactory() ..rootContextType(HelloWorld) ..run();` here https://github.com/angular/angular.dart/issues/919 – Günter Zöchbauer May 13 '14 at 20:31
  • You hopefully shouldn't need applyAuthorStyles or light-DOM templates to allow user styling of widgets. `::shadow` allows your users to explicitly target elements inside your shadow tree. I'd just add classes judiciously to internal elements so that they don't need to reply on potentially fragile structure. – Justin Fagnani May 20 '14 at 01:07
  • 1
    It looks like they are only flagging it as deprecated as a heads-up. There is currently no way around using Controller. – enantiomer2000 May 28 '14 at 18:37
  • @enantiomer2000 That's exactly how it is. There are some of the new things in the repository but not yet in the published package. – Günter Zöchbauer May 28 '14 at 20:42
  • 1
    There is a milestone for the Controller related changes, https://github.com/angular/angular.dart/issues?milestone=25 – user7610 Jul 25 '14 at 18:10