I\'m trying to build angular2 application for production for that I\'m following this blog. After my ngc successful compilation when the
So I fixed this problem I'll keep this short and simple. To fix this I read this blog deeply. As in section "The context property" The solution for this problem is that Don't use or create a private variable if you want to use it in the view directly when your are creating your build with AOT (i.e., Ahead Of Time) for production.
*for Example *
// component.ts
@Component({
selector: 'third-party',
template: `
{{ _initials }}
`
})
class ThirdPartyComponent {
private _initials: string;
private _name: string;
@Input()
set name(name: string) {
if (name) {
this._initials = name.split(' ').map(n => n[0]).join('. ') + '.';
this._name = name;
}
}
}
output: Property '_initials' is private and only accessible within class 'ThirdPartyComponent'.
Solution:
update this private _initials: string; to simply _initials: string;
For this answer Harish Gadiya provide me some help so thanx for that.