2
votes

I understand how to import one dart-polymer package into another package and use a component from the imported package.

There seems to be a difference in angular2-dart.

I created an angular2-dart component in package A and import it into package B. The specific component I want to use is NameComponent.

In polymer I would simply do the following to used the imported component's markup

<name-component></name-component>

Doing something similar does not work in angular2-dart.

I have not been able to find information on importing a component from one dart package into another for angular2-dart.

A graphical summary of what I am trying to do is shown below - package B. The name-component is from package A.

enter image description here

Does anyone know how this is done?

EDIT 1

After making the suggested corrections I receive the following

"P:\Program Files\Dart\dev\dart-sdk\bin\pub.bat" serve web --port=57435
Loading source assets...
Loading angular2 and dart_to_js_script_rewriter transformers...
Serving epimss_ng2_app web on http://localhost:57435
[DirectiveProcessor on epimss_ng2_reg|lib/components.dart]:
ERROR: Invalid argument (url): "Could not read asset at uri asset:epimss_ng2_reg/lib/name_component.html"
[Warning from TemplateCompiler on epimss_ng2_app|lib/app_component.ng_meta.json]:
Could not find Directive entry for name: NameComponent
. Please be aware that Dart transformers have limited support for reusable, pre-defined lists of Directives (aka "directive aliases"). See https://goo.gl/d8XPt0 for details.
Build completed with 1 errors.
[web] GET Served 13 assets.
[web] GET packages/epimss_ng2_reg/components.dart => Could not find asset epimss_ng2_reg|lib/components.dart.
[web] GET Served 17 assets.

I am going to place the components directory directly on lib and see if it makes a difference.

My package is actually packages/epimss_ng2_reg/src/components.dart.

1

1 Answers

0
votes

I can only think of 2 things you might be missing.

  • You need to add the component to directives @Component(..., directives: const [NameComponent]) af the parent component.
  • You need to add the Angular2 transformer in pubspec.yaml of the component

transformers:
  angular2