2

I'm confused about loading modules in Angular.dart ... (I hope).

So for angular.dart.ui let's say...I found myself putting in my main application under my main app module, type(Modal); ... but that wasn't enough apparently and I had to also add the import to the packages "timeout" and add type(Timeout); as well.

Do I need to keep adding type() all over the place and tracing back through someone else's code all the other dependencies they use??

Or should it just load all those when I inject, in this case, Modal?

I must be missing something here because adding the package you want and then testing in the browser and watching for "No provider" errors and adding all other dependencies one by one sounds like it slows down development, but I imagine the entire point of DI is to speed it up.

1 Answer 1

2

In you main you simply do

install(new ModalModule());

instead of

type(Modal) // old syntax
//...
bind(Modal) // new syntax

ModalModule is then installed as submodule which contains

  • TimeoutModule (which itself may contain some types)
  • ModalWindow and
  • Modal.

If you take a look at the source you will see that this way all you need is automatically registered for you.

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

3 Comments

Thanks! Exactly what I was after...And it's always done up front in the dart file that "MyAppModule" (I actually didn't rename that from the tutorial). But the main app module you create... Can I also install from somewhere else like a Component? Let's say only one tiny part of my big app here needs the module? I'm not sure if that makes for better performance? Or if it doesn't matter or what. I'm just trying to better understand how it works and best practices.
I guess yes (upfront) and no (performance) but I don't know for sure myself. If you really want to know you should create a new question.
Doesn't matter at this point. I might ask around later. Thanks again!

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.