I am starting to learn angular v2 and ionic v2.
In the ng2 hero tutorial they use a private keyword in constructor but in the ionic boilerplate source they use a public keyword in constructor.
angular2 tutorial
heroes: Hero[];
constructor(
private heroS: HeroService,
private router: Router
) { }
ngOnInit() {
this.heroS.getHeroes().then(heroes => {
this.heroes = heroes;
})
}
ionic tutorial
constructor(public navCtrl: NavController, public navParams: NavParams) {
}
After trans compile to es5
, public and private is the same in .js
file.
but I really don't understand what the difference is.