无法绑定到' navPush'因为它不是“a”的已知属性。

时间:2017-05-21 01:56:01

标签: angular testing jasmine ionic2

我有一个Ionic / Angular2应用程序,我正在使用Jasmine进行测试。但是当我运行它们时,我收到了错误

Can't bind to 'navPush' since it isn't a known property of 'a'

这些是我的导入

import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';

import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { async } from '@angular/core/testing';

import { SignIn } from './sign-in.component'

这是我的beforeEach

beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [ SignIn ],
      providers: [{provide: SignIn}],
      schemas: [CUSTOM_ELEMENTS_SCHEMA],
      imports: [ReactiveFormsModule]
 });

    fixture = TestBed.createComponent(SignIn);
    signInComponent = fixture.componentInstance;
});

这是我使用' a'

的地方
<a [navPush]="signUp" class="link-class">Not a member? Sign up now</a>

修改

组件:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Http } from '@angular/http';
import { AlertController } from 'ionic-angular';
import { ValidateEmail, ValidatePassword } from '../../../controller/custom-validations';
import { UserProfile } from '../../../models/user-profile';
import { UserHome } from '../userHome/user-home.component';

//Template used for the page which the user will use to log in
@Component({
  selector: 'page-sign-in',
  templateUrl: 'sign-in.component.html'
})

//Class used for the sign in of the member in the system
export class SignIn {
  signInForm: FormGroup;      
  signUp = SignUp;

  //Form used for the member to access the system
  constructor(public navCtrl: NavController, formBuilder: FormBuilder, private http: Http, public alertCtrl: AlertController) {
    this.signInForm = formBuilder.group({
      'email': [null, Validators.compose([Validators.required, ValidateEmail()])],
      'password': [null, Validators.compose([Validators.required, ValidatePassword()])],
    });
  }

我见过类似的问题,例如this

0 个答案:

没有答案