2

In the angular dart documentation it says best practice is to declare your controllers using controller annotations. But I get an error when trying to do that stating that annotations must be a constant variable. Digging into the source I can see that there is no controller annotation in angular dart 1.0

From package:angular/core/annotation.dart

export "package:angular/core/annotation_src.dart" show
    AttachAware,
    DetachAware,
    ShadowRootAware,

    Formatter,
    DirectiveBinder,
    DirectiveBinderFn,

    Directive,
    Component,
    Decorator,
    Visibility,

    DirectiveAnnotation,
    NgAttr,
    NgCallback,
    NgOneWay,
    NgOneWayOneTime,
    NgTwoWay;

Has the controller annotation been depreciated? If so, what is the best practice for instantiating a controller?

1 Answer 1

1

Controller were removed in Angular.dart 1.0.

There is a rootContext which is a controller initialized at application startup, otherwise use a component instead of a controller.

See for an example

Sign up to request clarification or add additional context in comments.

2 Comments

Can you please help me understand better how this should work in practice? For instance chapter 2 in the angular dart tutorial has me creating a controller using the controller annotation, then I use ng-repeat and access information in the controller. Since that is no longer how it works, what is the proper way to do it? I tried to just change the syntax from @controller to @component but there is no publish as property anymore either so I don't know how to access properties on the component. Also aren't components more like directives than controllers?
You should be able to just reference fields from the component without a prefix. I didn't check in detail but I think this is the tutorials already ported to Dart 1.0 github.com/vicb/angular.dart.tutorial/tree/1013-v1/Chapter_06/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.