Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 15:22
    crisbeto unlabeled #47589
  • 15:22
    crisbeto labeled #47589
  • 15:22
    crisbeto review_request_removed #47589
  • 15:22
    crisbeto review_request_removed #47589
  • 15:19
    Khym006 starred angular/angular
  • 15:11
    pullapprove[bot] review_requested #47586
  • 15:09
    pullapprove[bot] review_requested #47586
  • 15:09
    pullapprove[bot] review_requested #47586
  • 15:09
    pullapprove[bot] review_requested #47586
  • 14:59
    Mauryavaneesh starred angular/angular
  • 14:21
    mmartinezcasanova20 opened #47593
  • 14:13
    angular-robot[bot] labeled #27689
  • 14:13
    angular-robot[bot] commented #27689
  • 14:13
    angular-robot[bot] unlabeled #27689
  • 14:13
    angular-robot[bot] labeled #27689
  • 14:08
    PANKAJBAJAJ045 starred angular/angular
  • 13:09
    riellymoore starred angular/angular
  • 12:49
    crisbeto commented #47589
  • 12:48
    crisbeto synchronize #47589
Louis
@Louis-7
Anyone know how to get pure HTML in Angular2? When I want to get get parent HTML, there are always some angular selector in it. It's not pure.
Rob Wormald
@robwormald
the question would be why?
Louis
@Louis-7
no, the question is how to get the pure HTML
Sekib Omazic
@SekibOmazic
@robwormald I've changed your plunk like this:
http://plnkr.co/edit/jSkbUbsb9FGie73Y9Ysl
Now I get this ugly Error: Expression 'friends | async in App@4:12' has changed after it was checked
I don't see how friendshas changed. There is only one instance of friends.
Rob Wormald
@robwormald
right - why would you pull it from the DOM though - typically in most frameworks it would be unnecessary
Louis
@Louis-7
I know the selector will appear in HTML, but is there any method or something can help me get the pure HTML?
Rob Wormald
@robwormald
@SekibOmazic there's a bug with behavior subjects currently
not that it really matters, since you can use onPush and it fixes that issue
Aleš
@fxck
@robwormald do you think I'd be worth adding something like .getState() to the store?
Rob Wormald
@robwormald
@Louis-7 there's no such thing as "pure" html in this case
@fxck no
:)
that switches to an imperative API, basically defeats the purpose
Aleš
@fxck
but it's not really convenient to log out the current state with subscribes
Rob Wormald
@robwormald
store.subscribe(v => console.log(v))
?
Aleš
@fxck
console.log(store.getState())
Louis
@Louis-7
@robwormald oh? I don't want to get my selector but the HTML in selector.
Rob Wormald
@robwormald
@fxck that's less convenient, imo
behavior subjects have a .value property you can use
Louis
@Louis-7
there is a Component Reference, I can get innerHTML from it. But children's selector will be include...
Rob Wormald
@robwormald
@Louis-7 what are you trying to accomplish?
@fxck (Store is a BehaviorSubject)
but i'm not going to add an imperative method to do it.
Louis
@Louis-7
I use dynamicComponentLoader load some components into a canvas and I want to get the HTML. (components can also in another components, like nest view)
@robwormald
Sekib Omazic
@SekibOmazic
@robwormald Yes, OnPush fixes that. I understand it like this:
friends | sync "extracts" the list when it arrives and firends.next(newList) would create another list (different reference) and that's why I get that nasty error.
Is this correct?
Aleš
@fxck
well again, I don't think you'd ever use it for something other than debugging, in which case, it feels bit more convenient to call a function on Store, than to have to subscribe to it, or go digging in rx docs to see how to get value out of the subject : )
Rob Wormald
@robwormald
generally yes, but in this case its a specific bug in the async pipe @SekibOmazic
@fxck its literally Store.value
Vlado Tesanovic
@vladotesanovic
Is anoyne familiar with <ng-content> ? I know for directive "select". I cant find much in documentation about it.
Rob Wormald
@robwormald
its like peering into the guts of a promise. not kosher.
Vlado Tesanovic
@vladotesanovic
I also tried to implement custom directive on it, but it seems that does not work.
Sekib Omazic
@SekibOmazic
Is this the "right" way to handle Observables (return Observable from the service and use async pipe in the template)? @robwormald
Aleš
@fxck
yes
there are very few or no cases at all where you'd want to handle observables manually instead of using the async pipe
Rob Wormald
@robwormald
yep. although really, you've already got the subject available on the service
this.friends = friendsService.friends
Sekib Omazic
@SekibOmazic
In my app (which is too big for plunker) I read friends from backend and ngFor them in a list like this: *ngFor="#friend of firends | async" [routerLink]="['./Friend', {'id': friend.id}]"
But in the Friend component I need an empty Friend object in order to render the template for the first time (until Friend Object arrives). How do you deal with it?
Aleš
@fxck
with elvis most likely
(friend | async )?.name
Louis
@Louis-7
um... anyone know something about my question?
Sekib Omazic
@SekibOmazic
yes but he's not using async pipe at all, he's handling it manually in the component
@Louis-7 the short answer is no, the DOM is what the DOM is. there's no way to get any version other than how it exists at the current time
the longer answer is you're probably thinking about this incorrectly, imho, so perhaps make a plunker to demonstrate what you're trying to do
basically the entire point of Angular (and React, for that matter) is to avoid touching the DOM