我可以使用一些帮助,我正在学习ANGULAR 2路由,我收到了这个错误:
app / app.component.ts(7,12):错误TS2345:类型'{的参数 selector:string; templateUrl:string;指令:( typeof PeliculasListComponent | typeof Peli ...'不可分配给 类型'{selector?:string;的参数;输入?:string [];输出?: 串[]; properties?:string [];事件?:strin ......'。种类 财产'指令'是不相容的。 类型'(typeof PeliculasListComponent | typeof PeliculasFooterComponent | typeof“C:/ UwAmp / www / curso-ang ...'不是 可分配给类型'(Type | any [])[]'。 输入'typeof PeliculasListComponent | typeof PeliculasFooterComponent | typeof“C:/ UwAmp / www / curso-angu ...”不是 可分配给'Type |类型任何[]'。 键入'typeof“C:/UwAmp/www/curso-angular/app/components/contacto.component”'不是 可分配给'Type |类型任何[]'。 键入'typeof“C:/UwAmp/www/curso-angular/app/components/contacto.component”'不是 可分配给'any []'。 类型'typeof“C:/UwAmp/www/curso-angular/app/components/contacto.component”'中缺少属性'length'。 app / app.component.ts(16,14):错误TS2345:类型'的参数({路径: 串; name:string; component:typeof PeliculasListComponent; useAsDefault:boolean; } ...'不能分配给类型的参数 'RouteDefinition []'。输入'{path:string; name:string;零件: typeof PeliculasListComponent; useAsDefault:boolean; } ...' 不是 可分配给'RouteDefinition'类型。 输入'{path:string; name:string;组件:typeof“C:/ UwAmp / www / curso-angular / app / components / contac ...”不是 可分配给'RouteDefinition'类型。 属性“组件”的类型不兼容。 键入'typeof“C:/UwAmp/www/curso-angular/app/components/contacto.component”'不是 可分配给'Type |类型ComponentDefinition”。 键入'typeof“C:/UwAmp/www/curso-angular/app/components/contacto.component”'不是 可分配给'ComponentDefinition'类型。 'typeof“C:/UwAmp/www/curso-angular/app/components/contacto.component”'类型中缺少属性'type'。
这是我的代码:
import {Component} from "angular2/core";
import {PeliculasListComponent} from "./components/peliculas-list.component";
import {PeliculasFooterComponent} from "./components/peliculas-footer.component";
import ContactoComponent from "./components/contacto.component";
import {ROUTER_DIRECTIVES, RouteConfig, Router} from "angular2/router";
@Component({
selector: "my-app",
templateUrl: "app/views/peliculas.html",
directives: [PeliculasListComponent,
PeliculasFooterComponent,
ContactoComponent,
ROUTER_DIRECTIVES]
})
@RouteConfig([
{path: "/peliculas", name:"Peliculas", component: PeliculasListComponent, useAsDefault: true},
{path: "/contacto", name:"Contacto", component: ContactoComponent}*/
])
export class AppComponent{
public titulo:string = "Peliculas con angular" ;
}
您是否有任何想法如何解决?谢谢!
答案 0 :(得分:0)
您最有可能使用角度版本的过期版本,如评论中所述。 因为根据组件装饰器中的最新文档 没有指令属性:
https://angular.io/docs/ts/latest/api/core/index/Component-decorator.html
从angular.io的指南开始,有很多例子。
否则从角度种子项目开始,配置所有内容:
https://github.com/angular/angular-seed
直接从角度角度试用本指南,它涵盖了您开始所需的几乎所有内容: