I'm currently working on implementing the angular 2 onInit feature, but I keep encountering an error in the console:
Error: ReferenceError: OnInit is not defined(...)
Could someone please help me identify what mistake I may be making?
Below is my component code for reference:
import { Component, OnInit } from 'angular2/core';
import { ViewEncapsulation } from 'angular2/core';
@Component({
selector: 'Landing',
templateUrl: '/app/views/landing.html',
styleUrls: ['../app/styles/landing.css'],
encapsulation: ViewEncapsulation.None
})
export class LandingComponent implements OnInit {
function checkOverflow() {
var element = document.querySelector('.appContainer');
if( (element.offsetHeight < element.scrollHeight) || (element.offsetWidth < element.scrollWidth)){
// your element have overflow
console.log('OVERFLOW!');
}
else{
console.log('NO OVERFLOW');
}
}
OnInit() {
checkOverflow();
}
}