Я пытаюсь реализовать функцию угловой 2 OnInit, но я получаю следующее сообщение об ошибке в консоли:Angular2 - OnInit не определен
Error: ReferenceError: OnInit is not defined(...)
Может кто-нибудь указать на то, что я делаю не так?
Это мой компонент:
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();
}
}