Angular 2.0 lifecycle and Typescript -


i have angular 2.0 component , wanted add lifecycle events (angular 2.0 alfa 35).

i looking @ post reference, typescript gave me errors using

import {component, view, eventemitter, oninit} 'angular2/angular2';

(error on oninit). quick @ angular2 code revealed export uses oninit (with capital o). changed import code lifecycle event still oninit. component (i cannot make oninit event happen):

import {component, view, eventemitter, oninit} 'angular2/angular2';  @component({   selector: 'theme-preview-panel-component',   properties: ['fontsize'],   lifecycle: [oninit] }) @view({     templateurl: '../components/theme-preview-panel-component/theme-preview-panel-component.tpl.html', }) export class themepreviewpanelcomponent {   fontsize: string;   constructor() {   }    oninit() {     //this code not being called   } } 

edit

as @eric martinez mentioned below, solution is:

import {component, view, eventemitter, lifecycleevent} 'angular2/angular2';      @component({       selector: 'theme-preview-panel-component',       properties: ['fontsize'],       lifecycle: [lifecycleevent.oninit]     })     @view({         templateurl: '../components/theme-preview-panel-component/theme-preview-panel-component.tpl.html',     })     export class themepreviewpanelcomponent {       fontsize: string;       constructor() {       }        oninit() {         //now code being called       }     } 


Comments

Popular posts from this blog

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -