2016-11-25 89 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 ], 
})