I have a 'job' component that will load a given job from Mongo based on an 
id retrieved from the router. 

I also have a 'job-form' component that is a sibling component and I want 
to initialise the input fields with the current job data. I'm currently 
retrieving the job data from an observable (rxjs BehaviourSubject) in a 
service but since the data from mongo is asynchronous the data I try to 
initialise the form with is undefined when the form is created So I get:

TypeError: Cannot read property 'name' of null

I tried using:* job?.name* but then I get:

The '?.' operator cannot be used in the assignment at column 11 in 
[job?.name=$event]  

I also tried using the async pipe but I get:

Cannot have a pipe in an action expression at column 12 in [job.name | 
async=$event]


So whats the best approach here?
Also, if i've already loaded my job in my 'job' component can I not just 
get that variable from my 'job form' component without having to call it up 
from Mongo for a second time? Currently I have to call my service function 
from my job form component as well to get the subscription to work, e.g.:

  getJobById(id) {
    this.subscription = this.subscribe('jobs', () => {
      this.job$.next(Jobs.findOne({"_id":id}));
    }, true); 
  }


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to