Angular extend base component

Source: https://stackoverflow.com/questions/49320759/angular-4-extend-base-component

Since base class doesn't need to be instantiated on its own, it's abstract class and doesn't need to have @Component decorator.
If it has dependencies, and there's a chance that constructor will be omitted in child classes and inherited, base class should have @Injectable decorator:
@Injectable()
export abstract class BaseComponent implements OnInit {
  constructor(public dep: Dep) {}

  ngOnInit() {}
}

@Component({
  selector: 'app-child',
  templateUrl: './child.component.html',
  styleUrls: ['./child.component.css']
})
export class ChildComponent extends BaseComponent {
  // dummy constructor can be omitted
/*
  constructor(dep: Dep) {
    super(dep);
  }
*/
}

Không có nhận xét nào:

Cold Turkey Blocker

 https://superuser.com/questions/1366153/how-to-get-rid-of-cold-turkey-website-blocker-get-around-the-block Very old question, but still wan...