viewProviders property

List<Object> viewProviders

Defines the set of injectable objects that are visible to its view DOM children.

Simple Example

Here is an example of a class that can be injected:

class Greeter { greet(String name) => 'Hello ${name}!'; }

@Directive( selector: 'needs-greeter' ) class NeedsGreeter { final Greeter greeter;

NeedsGreeter(this.greeter); }

@Component( selector: 'greet', viewProviders: Greeter , template: '', directives: NeedsGreeter ) class HelloWorld { }


final List<Object> viewProviders