使用* ngIf" condition"在angular2

时间:2017-06-28 09:01:06

标签: angular

我使用* ngIf时出现问题,当我使用它时,控制台调用错误"对象{__zone_symbol__error:错误,fileName:Getter,lineNumber:Getter,columnNumber:Getter,message:Getter,name: Getter,stack:Getter,originalStack:Getter,zoneAwareStack:Getter,toString:value(),4 more ...}"

有代码:component.html

<div *ngIf="actPage == 0" class="landing">
        <header>
            <h1>{{actPage}}</h1>
        </header>
        <div class="cards-wrap">
            <div class="cards cards--wide">
                <a class="cards__card" href="landing.html">
                    <img src="/res/images/apply-long.svg"/>
                    <h2>Click here and fill out your profile information</h2>
                    <p>To get started with your application you must complete your profile information</p>
                </a>
            </div>
        </div>
    </div>

module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { StudentRegisterComponent } from './student-register.component';
import { BrowserModule } from '@angular/platform-browser';

@NgModule({
    imports: [
        CommonModule
    ],
    declarations: [ StudentRegisterComponent ],
})
class MyComponentModule {}

和component.ts

    import { Component } from '@angular/core';
import { RegistrationSharingData, PagesData } from '../student.data';
@Component({
    moduleId: module.id.toString(),
    selector: 'student-register',
    templateUrl: 'student-register.component.html',
    providers: [ RegistrationSharingData, PagesData ]
})
export class StudentRegisterComponent {
    actPage: number;
    service;
    pages;
    constructor( service: RegistrationSharingData, pages: PagesData){
        this.actPage = pages.getPage();
        this.service = service;
        this.pages = pages;
    }

    nameChange(str){
        this.service.setName(str);
        console.log(str);
    }

}

我想补充说{{actPage}}效果很好,请帮助我,问题* ngIf一直迫害我,角度版本:2.4.1

0 个答案:

没有答案