1

私はAngular2で簡単なngForを実装しようとしていますが、何が間違っていたのかわからないので、 'Generic TYPE Arrayは1つの引数を必要とします。私はAngluar2を使用していない汎用型 '配列<T>'には1つの型引数が必要です。 - Angular2

import { Component } from '@angular/core'; 


    @Component({ 
     selector: 'my-app', 
     templateUrl:'./app.component.html',      
    }) 
    export class AppComponent { 
      clients:Array; 
      doctors:Array; 
      constructor(){ 
       this.clients=["Client1", "Client2", "Client3"]; 
       this.doctors=["Doctor1","Doctor2","Doctor3"]; 
      } 


    } 
+0

読むジェネリックコンセプト最初 –

答えて

2

溶液1:

clients: String[]; // if type cant be determined use 'any[]' 
    doctors: String[]; 

溶液2:プログラミング

clients: Array<String>; // if type cant be determined use '<any>' 
    doctors: Array<String>; 
2

を好むが、私はあなたの配列が保持しようとしているタイプを知っているので、それ自身の上の配列の代わりにArray<String>を使用することで、ソリューションを信じてください。

注:Stringを文字列プリミティブのangular2タイプ名に置き換えます。

関連する問題