Angularjs 角度2异常:TypeError:无法读取属性';下一个';未定义的

Angularjs 角度2异常:TypeError:无法读取属性';下一个';未定义的,angularjs,angular,angular2-services,Angularjs,Angular,Angular2 Services,我正在尝试将一个变量从我的服务更新到组件。当我试图在组件中订阅它时,我得到了一个错误。谁能帮帮我吗 import {Injectable, } from 'angular2/core'; import {Router} from 'angular2/router'; import {MasterComponent} from '././master/master.component'; import 'rxjs/Rx'; import { Observable } from "rxjs/Obse

我正在尝试将一个变量从我的服务更新到组件。当我试图在组件中订阅它时,我得到了一个错误。谁能帮帮我吗

import {Injectable, } from 'angular2/core';
import {Router} from 'angular2/router';
import {MasterComponent} from '././master/master.component';
import 'rxjs/Rx';
import { Observable } from "rxjs/Observable";
import { Subscription } from "rxjs/Subscription"
import {Subject} from "rxjs/Subject" 

@Injectable() 
export class ConnectService
{
  showValues: string;
  public showValuesChange: Subject<string> = new Subject<string>();

  constructor() {
    this.showValues="1";
  }

  recvNotify(m) {
    buttonName = innervalue;
    console.log("ELSEinnervalue",buttonName);
    switch (buttonName) {
      case "0x01010000": 
        console.log('showValue==1');
        this.showValues = "1";
        this.showValuesChange.next(this.showValues);
        break;
      case "0x01020000":
        console.log('showValue==2');
        this.showValues = "2";   
        this.showValuesChange.next(this.showValues);
        $('#showValue').prop("value",2); 
        break;
      default:
        console.log('showValue==3');
        this.showValues = "3";  
        this.showValuesChange.next(this.showValues);
        break;
    }                      
  }
}

你在哪里调用
recvNotify
angular2/core',angular2/router,@angular2/router
你在使用多个angular2版本吗?我有另一种方法连接到websocket,从那里获得连接后,我调用
client.onnotify=this.recvNotify不,我没有使用。删除它谢谢你纠正我。你能帮我解决另一个问题吗?以数字2结尾的模块说明符表示你正在使用非常旧的测试版。我建议您升级,因为您将很难找到支持。请注意,升级将涉及重写大量的应用程序并重组几乎所有的应用程序。
import {Component} from 'angular2/core';
import {ConnectService} from '../connect.service';
import {Router} from 'angular2/router';
import 'rxjs/Rx';
import {Observable} from 'rxjs/Observable';
import {Subscription} from 'rxjs/Subscription';

@Component({
  selector: 'Master',
  templateUrl: './app/master/master.component.html',
  providers: [ConnectService]
})

export class MasterComponent {
  //showValue: any;
  public showValues: string;
  //show: any;

  constructor(
    public connectService: ConnectService,
    public _router: Router,
    public _subscription: Subscription){
    if(localStorage.getItem("clientStatus")=='connected'){     
      this.showValues = connectService.showValues;
      this._subscription = connectService.showValuesChange.subscribe((value) => {
        this.showValues=value;
        console.log("import {Observable} from 'rxjs/Observable';",this.showValues);
      });

      this._router.navigate(['Master']);
    } else {
      this._router.navigate(['Home']);
    }
  }

  ngOnDestroy() {
    this._subscription.unsubscribe();
  }
}