Jack Murphy
Jack Murphy

Reputation: 3020

Why is Angular Dart 2 ViewEncpasulation no longer accepting enums?

In Angular Dart 2 Alpha 35 the @view component accepted an enum value:

@View(
  styleUrls: const ["package:tickets/client/components/flight_display/flight_display.css"],
  templateUrl: "package:tickets/client/components/flight_display/flight_display.html",
  directives: const[CORE_DIRECTIVES],
  encapsulation: ViewEncapsulation.NONE
)

The encapsulation: ViewEncapsulation.NONE now throws the following error:

Error:(11, 18) Arguments of a constant creation must be constant
 expressions

Question: What is the proffered way to pass the value from an enum to the ViewEncapsulation object?

Context

Here is the Enum for the Angular.Dart 2 Lib:

enum ViewEncapsulation {
  /**
   * Emulate scoping of styles by preprocessing the style rules
   * and adding additional attributes to elements. This is the default.
   */
  Emulated,
  /**
   * Uses the native mechanism of the renderer. For the DOM this means creating a ShadowRoot.
   */
  Native,
  /**
   * Don't scope the template nor the styles.
   */
  None
}

Upvotes: 0

Views: 237

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657496

There is a , missing after const[CORE_DIRECTIVES] (found by https://github.com/angular/angular/issues/4169#issuecomment-140011891) and ViewEncapsulation.NONE should be ViewEncapsulation.None

@View(
  styleUrls: const ["package:tickets/client/components/flight_display/flight_display.css"],
  templateUrl: "package:tickets/client/components/flight_display/flight_display.html",
  directives: const[CORE_DIRECTIVES],
  encapsulation: ViewEncapsulation.None
)

Upvotes: 1

Related Questions