These are chat archives for angular/angular-2-ionic-2

23rd
Mar 2015
Andrew Joslin
@ajoslin
Mar 23 2015 18:13
so regarding an earlier question again...
how do we imperatively create angular 2 components?
the new version of $compile('<my-component>')
we need this for many things
we tried playing with compiler and TemplateResolver but couldn't quite get it to work
I'll try again now...
Miško Hevery
@mhevery
Mar 23 2015 20:06
Have a look at @DynamicComponent let mi find a link
We can probably stream line the API for public use.
Let me know if you need more in-depth explanation
Andrew Joslin
@ajoslin
Mar 23 2015 20:20
ah. this looks great.
I'll try the example in the docs and let you know if I have problems
..after I figure out how to compile angular master
Miško Hevery
@mhevery
Mar 23 2015 20:48
SGTM
Andrew Joslin
@ajoslin
Mar 23 2015 21:47
awesome, it works!
I get blue text and red bg
my next question: can I have my component dynamically load without a template?
This message was deleted
This message was deleted
This message was deleted
if I take out the template for RedBgStyler and BlueBgStyler, it throws a no template error
even if I make BlueTextStyler and RedBgStyler decorators
Andrew Joslin
@ajoslin
Mar 23 2015 22:13
I also tried loading a component with a template first
before the decorators without templates
thinking maybe it just wants a template
I still get the same 'no template' errors on the decorators
Andrew Joslin
@ajoslin
Mar 23 2015 22:15
yeah, sorry there's a lot in the screenshot
I'm using a dynamiccomponent
Miško Hevery
@mhevery
Mar 23 2015 22:15
DynamicComponent can not have @Template
Andrew Joslin
@ajoslin
Mar 23 2015 22:15
to load Components/Decorators onto itself
I also did it iwthout the template
one sec, updating
this works perfectly if I add a template to both decorators
Miško Hevery
@mhevery
Mar 23 2015 22:16
Have you looked at tho docs?
Andrew Joslin
@ajoslin
Mar 23 2015 22:16
which is weird, because decorators shouldn't need templates anyway
Miško Hevery
@mhevery
Mar 23 2015 22:16
I am confused. What exactly are you trying to achieve.
Andrew Joslin
@ajoslin
Mar 23 2015 22:17
OK, for now, I'm trying to add two decorators to a component.
I have dynamic-component on the right in that screenshot
it lets me add two decorators, which both in this example just style the component's element
but only if I add templates to them
I wish I could get it on a plunkr...
I'll try
It's hard to just work with screenshots like this.
Miško Hevery
@mhevery
Mar 23 2015 22:17
remove services from @DynamicComponent
Andrew Joslin
@ajoslin
Mar 23 2015 22:18
it doesn't work unless I have the services there
Miško Hevery
@mhevery
Mar 23 2015 22:18
DynamicComponent can not let you add decorators. This sentence makes no sense to me.
Andrew Joslin
@ajoslin
Mar 23 2015 22:18
I just commented them and it says 'No provider for PrivateComponentLoader'
okay, I'll open an issue with a clearer use case
I don't wanna waste your time this way
with exactly what I'm trying to do, instead of being confusing
Miško Hevery
@mhevery
Mar 23 2015 22:20
Can you file a bug on that. That does not seem right. (on needing PrivateComponentLoader in the services.)
Decorators can not have templates. That is a bug as well, file an issue.
Ohh I get it!
You con not dynamically load Decorators! line 17/18 is wrong
Andrew Joslin
@ajoslin
Mar 23 2015 22:23
it does let me dynamically load decorators, though
if I add a template
Miško Hevery
@mhevery
Mar 23 2015 22:23
Instead GoodContentStyler needs to list them in the @Template.decorators
It is a bug, please file, Only components can be dynamically loaded
Andrew Joslin
@ajoslin
Mar 23 2015 22:23
OK
dynamically loading decorators is a big deal for us, though
I'm writing out the use case in an issue now
I'll open an issue for the services of PrivateComponentLoader, and my usecase of dynamic decorators for discussion
Miško Hevery
@mhevery
Mar 23 2015 22:24
Please write a use case. Dynamic loading of decorators does not make conceptual sense in our code.
Do you wont to video chat for a bit?
Andrew Joslin
@ajoslin
Mar 23 2015 22:25
sure, that would be great if you have a few minutes
Miško Hevery
@mhevery
Mar 23 2015 22:25
yes
Andrew Joslin
@ajoslin
Mar 23 2015 22:25
starting a hangout, one sec
Andrew Joslin
@ajoslin
Mar 23 2015 22:38
posted angular/angular#1062 and angular/angular#1063
thanks a lot misko.
One more question: if I have
class ContentContainer {
}

@Component(...)
class Tabs extends ContentContainer {
}

@Component(...)
class SomeComponent {
  constructor( @Ancestor() container: ContentContainer ) {
   }
}
I know this won't work, but what's the best way to do this sort of thing?
Have a ComponentA inherit from ComponentASuper, then have another element query for any ComponentASuper
Without having to have a huge selector maintained for ComponentASuper
Miško Hevery
@mhevery
Mar 23 2015 23:22
Your example should work.
But we have not implemented one more thing, which you need.
angular/angular#709