Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export function Mandatory() {
- return function(target: any, propertyKey: string) {
- const ngOnInit = target.constructor.prototype.ngOnInit;
- target.constructor.prototype.ngOnInit = function(...args) {
- if (target[propertyKey] === null || target[propertyKey] === undefined) {
- throw Error(
- `mandatory property: ${propertyKey} not initialized. Current value is ${target[propertyKey]}`
- );
- }
- return ngOnInit && ngOnInit.apply(this, args);
- };
- };
- }
Add Comment
Please, Sign In to add comment