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

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -