Glad to hear that you solved your problem! BTW, since you mention abstract classes....I had a similar issue recently, where I created an abstract base class for components (which I had never done before), and annotated the abstract class with @Component. Similarly to your issue, this worked fine with a non-prod build, but failed with a prod build. Removing the un-necessary annotation fixed my issue too.
------------------------------ Rich Freedman <http://greybeardedgeek.net> <http://twitter.com/#!/greybeardedgeek> <http://www.linkedin.com/profile?viewProfile=&key=13484238&trk=tab_pro> On Thu, Jan 24, 2019 at 4:39 AM Gunnar <[email protected]> wrote: > Hi Sander, hi Richard! > > Finally I got the mistake, when I faced it in my new project again: > > The error had been caused by a parameter in a constructor of the > DataService class, annotated as "Injectable". This parameter ("uri") had > been added to provide the data-object specific relative path to a backend > service, when this constructor is called by a child-class like > UserDataService: > > @Injectable({ > providedIn: 'root' > }) > export class DataService { > > url: string; > > constructor(uri: string, private http: HttpClient) { > this.url = environment.apiUrl + uri; > } > .. > > > This seems to be no issue for the development compiler. But the production > compilation breaks. The reason seems to be that Angular does not know what > to inject into the uri parameter as actually there is nothing to inject. > And this parent class shall not be injected anyway, but only its childs. > But I thought if a child class is injectable the parent class needs to be > injectable, too. > But this does not seem to be the case. > Therefore I changed the coding now by removing the "Injectable" Attribute > from DataService and making it an "abstract class". So only it's child > classes are now injectable - without the "uri" parameter in the > constructor. And this way everything seems to be fine now (at least the > unit-tests are all green). > > And shame on me!!! > I recognized now also a warning in the compilation for production that > told me: > > *activeWarning: Can't resolve all parameters for DataService in > Z:/Data/Software_Entwicklung/EmPort/emport-ui/src/app/services/data.service.ts: > ([object Object], ?). This will become an error in Angular v6.x* > > > :-o > > So I am so sorry for carelessly not mentioning this warning in my posting. > I just did not understand it and did not assume that it could relate to the > error later in the compilation process. :-( > > Nevertheless equipped with your helpful advises, I.. > > - was able to track down the error by following your advise, Sander, > to rebuild the project step by step again! (and yes, would have been easier > by looking more carefully at the compilation messages..) > - have set up a versioning and testing structure to get regular > fallback scenarios for future issues in place, like Richard advised. > > So thanks a lot for your helpful advises again and next time I promise to > be more careful! > > Best regards > > Gunnar > > > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Angular and AngularJS discussion" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/angular/mBM_xy4Vt-s/unsubscribe. > To unsubscribe from this group and all its topics, 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. > -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" 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.
