9
が定義されていないのOnInitは、私は、角2のOnInit機能を実装しようとしているが、私は、コンソールに次のエラーを取得する:Angular2 -
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();
}
}