小编Tim*_* W.的帖子

Angular2:TypeError:无法读取未定义的属性'Symbol(Symbol.iterator)'

我是观察者的新手,并在Angular2博客中尝试了Christoph Burgdorf的Observables的基本自动完成变体.运行此代码会产生:

EXCEPTION:TypeError:无法读取未定义的属性'Symbol(Symbol.iterator)'

在ingredientservice ... rawsearch发出REST get调用之后.警报还会弹出[object Object]消息.我已经验证了端点运行正常.

任何有关如何调试此建议的建议将不胜感激.

ingredientservice.ts等待对文本字符串进行更改,对其进行去抖动并执行REST调用以从端点获取自动完成匹配.

import {Injectable} from 'angular2/core';
import {Http} from 'angular2/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/map';

@Injectable()
export class IngredientService {
  endpoint_url: String = "http://localhost:5000/ingredient/";
  results: Observable<Array<string>>;
  constructor(private http: Http) { }

  search(terms: Observable<string>, debounceDuration = 400) {
    return terms.debounceTime(debounceDuration)
      .distinctUntilChanged()
      .switchMap(term => this.rawSearch(term));
  }

  getData: Object[];
  rawSearch(term: string) {
    console.log(term);

    this.http.get(this.endpoint_url + term)
      .subscribe(
      res => {
        this.getData = res.json(); …
Run Code Online (Sandbox Code Playgroud)

angular2-services angular

7
推荐指数
1
解决办法
1万
查看次数

运行Angular2 ver.2.0.0-alpha.44时不存在属性问题

Angular2的新手,试图在我的本地系统上运行这个plunkr项目.我收到以下错误:

错误:(25,23)TS2339:'PeopleService'类型中不存在属性'people'.错误:(26,39)TS2339:'人''类型中不存在属性'人'

在线:
peopleService.people .subscribe(people => this.people = people);

我有理由相信我已正确设置了环境,因为我正在运行其他基本组件.

people.ts文件:

import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2'  
import {PeopleService} from './peopleService'  
import {Person} from './person'

@Component({  
    selector: 'my-app',  
    providers: [PeopleService]  
})  
@View({
    template: `
    <div>
      <h2>Hello Angular2!</h2>
      <my-person
        *ng-for="#person of people"
        [name]="person.name"
        (hello)="saidHello($event)">
      </my-person>
    </div>
  `,  
        directives: [CORE_DIRECTIVES, Person]  
})  
export class People {  
    constructor(public peopleService:PeopleService) {  
        peopleService.people  
            .subscribe(people => this.people = people);  
    }  
    saidHello($event){  
        alert(`You said hello to ${$event}`)  
    }
}
Run Code Online (Sandbox Code Playgroud)

peopleService.ts文件中的类似错误:

错误:(8,14)TS2339:'PeopleService'类型中不存在属性'people'.

//a simple …
Run Code Online (Sandbox Code Playgroud)

typescript angular

4
推荐指数
1
解决办法
3万
查看次数

标签 统计

angular ×2

angular2-services ×1

typescript ×1