ngParty / ng-metadata

Angular 2 decorators and utils for Angular 1.x

Home Page:https://hotell.gitbooks.io/ng-metadata/content/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ngOnInit losing reference to this

ryanpager opened this issue · comments

So I am currently converting our angular-1 app over to use ng-metadata so we can start the transition into angular-2 style code. Everything seems to work ok, but our lifecycle events cannot access the this property, it is always undefined.

Is there something im missing? An example of our code that has problems,

import { Component, Inject, OnInit } from 'ng-metadata/core'

import * as template from "./template.html"

@Component({
  selector: 'login-route',
  template: template
})
export class LoginRoute implements OnInit {
  constructor(@Inject('$http') private $http: ng.IHttpService) {
    console.log('this.$http is ok', this.$http)
  }

  ngOnInit() {
    console.log('this.$http is undefined', this.$http)
  }
}

Please provide a plunkr or demo repo(even better with failing test) when submitting issues like this, it helps to quickly fix the bug or particular issue which may not be a ng-metadata bug

here is starting plunker which you can use ( it's also in docs ) https://plnkr.co/edit/Bds0Bk?p=preview

also please always state what versions of dependencies are u using.

Last but not least there is this thing called CONTRIBUTING GUIDE LINES which is here for a reason right ? :)

Don't worry about it @Hotell, we've ditched ng-metadata as a team and we'll use something else. Thanks for the condescending response at the end. 👍

JUST WOW!

Thanks for your contribution @ryanpager. Every user who will skim through issue log in the future will be very thankful that this was solved in this way.

If you think my response was arrogant, then I'm sorry, but maybe you should wake up from some strange dream.
This is open source, I'm doing this for free, you are earning money, so please next time try to finish things and not complaining. All I wanted is a plnkr and versions that u r using, if you are unable to provide those basic things then well, good luck I guess.

Anyway for anyone reading this, here is the Plunker, and ofc everything works ( it took me 30 seconds to create it )

@Hotell

Lets go over a couple thing heres. First, you are very correct, I am a business, and as such I have to abide by an NDA -- which means plunkr is out of the question. I understand this is open source, but at the same time, if you helped write the library, you should be able to point someone in the right direction on where to look without a plunkr. If you recall the slack question; it was why this would happen, it was not fix this for me.

Second, your response about Contributing Guidelines is condescending. I never called you arrogant. If you want to enforce people adding in data to issues, then it might help if you pre-filled issues with the information you need.

Given that we are under deadlines because we are a business, we had to ditch the library and go what works -- which is a completely reasonable response. It does not mean the library is crap, it simply means it doesn't fit our needs.

I apologize if you don't like my response, or you think I'm a jerk -- but not everyone works in open source space -- which is why I came to the slack to have a conversation first. If I offended you personally, I apologize, that was not the intention.

@ryanpager you should learn how to minimize amount of code in order to either figure out what is core issue by yourself or be able to pass it to someone else, as CTO you should know that. So NDA is out of the question as nobody is interested in any huge business logic to debug in Plunker. If your company has NDA which cover generic code you should stop using open source right now, maybe your NDA covers this conversation as well.

From my point of view, you have raised and ditched question without thinking that some else will spend his time on that and comment

Thanks for the condescending response at the end. 👍

is just 🍒 on the top.

so please think bit that there are real people behind each open source software and they obviously want to help everybody, but you have to respect their personal time which they are sacrificing in your favour.

As open source user you works in open source as anybody else, so please be kind worker otherwise you are poisoning our environment.

p.s. try to do similar thing on the street with real people and you can guess how they will react to your condescending requests

@elmariofredo

Asking a question about how something works is not a condescending request. It takes 5 seconds to say "look at this library file to see how this lifecycle work." Its not a difficult task. A traditional NDA covers the business logic within the code, not the libraries it uses. So you are absolutely incorrect here.

Look, I've apologized, I understand both sides of the coin, and I once again I apologize if this came across the wrong way. The library is not crap, its just an unfortunately situation.

@ryanpager raising request and withdrawing it in 4 hours to person which you are not paying without proper apology and even with already mentioned comment is condescending to me.

Without plunker and similar tools don't expect anybody to help you in open source word. You have started discussion about NDA covering why you are not allowed to create plunker so that's why I raised my suggestion.

I don't want to be harsh on you, just I don't tolerate any such behaviour. Everybody has to be aware how to behave on internet. I'm surprised that we still have to remind this to each other these days that we interact with real people and not machines.

commented

I had the same issue as @ryanpager.
Changing Typescript's target to "es5" fixes the issue.
https://plnkr.co/edit/jzn8loW899cnTWS0eXyP?p=preview

interesting! thx for creating workable demo with issue @fantasia949 .

Using pure es6 is still a edge point at this moment because browser support vary