2016-11-25 109 views
1

我采用了棱角分明的版本2.1.2,我有错误“模板解析错误:(...)”当我运行此代码:角2:* ngIf - 模板解析错误

组件的HTML:

<div *ngIf="isLoggedIn"> 
    <br /> 
    <div class="valign-wrapper"> 
    <div class="valign center" style="width:100%"> 
     <a class="waves-effect waves-light btn"> 
     <i class="mdi mdi-vk"></i> 
     Connect 
     </a> 
    </div> 
    </div> 
</div> 

组件的代码:

import { Component } from '@angular/core'; 

@Component({ 
    moduleId: module.id, 
    selector: 'home', 
    templateUrl: 'home.component.html', 
    styleUrls: ['home.component.css'], 
}) 

export class HomeComponent { 
    isLoggedIn = false; 
} 

模块:

import { NgModule } from '@angular/core'; 
import { RouterModule } from '@angular/router'; 

import { HomeComponent } from './home.component'; 

import { routing } from './home.routes'; 

@NgModule({ 
    imports: [ 
    RouterModule, 
    routing 
    ], 
    declarations: [ HomeComponent ], 
}) 

export class HomeModule {} 

但是,如果我在html代码中使用例如'{{isLoggedIn}}'值没有任何错误显示。

请帮帮我,我忘了什么?

+0

@GünterZöchbauer,谢谢,因为我以为我忘了smthng :) – giarmul

回答

2
@NgModule({ 
    imports: [ 
    RouterModule, 
    routing, 
    CommonModule // <<<< added 
    ], 
    declarations: [ HomeComponent ], 
})