Refer to code:
https://plnkr.co/edit/j5qPROsWX2mGCQMIigee?p=info
It goes something like:
import {Component, Inject, provide} from 'angular2/core';
import {Hamburger} from '../services/hamburger';
@Component({
selector: 'app',
template: `Bun Type1: {{ bunType1 }}
<br/>
Are these same instances : {{equality}}
`
})
export class App {
bunType: string;
constructor(@Inject(Hamburger) h1, @Inject(Hamburger) h2) {
this.bunType1 = h1.bun.type;
if (h1 === h2) {
this.equality = 'true'; //this is the outcome
} else {
this.equality = 'false';
}
}
}
In the app class, we are injecting two different variables h1 and h2. I call them different because I believe the angular2 framework does something like
h1 = new Hamburger()
h2 = new Hamburger()
and now injects two different objects into App constructor. If that is the case then howcome we get the result (h1 === h2) = true?