我可以使用一些帮助,我正在学习ANGULAR 2路由,我收到此错误:
app / app.component.ts(7,12):错误TS2345:类型'{selector:string; templateUrl:string;指令:( typeof PeliculasListComponent | typeof Peli ...'不能分配给'{selector?:string;输入?:string [];输出?:string [];属性?:string []; events?: strin ...' . 属性'指令'的类型是不兼容的 . 类型'(typeof PeliculasListComponent | typeof PeliculasFooterComponent | typeof“C:/ UwAmp / www / curso-ang ...”不能分配给''类型'| [])[]' . 输入'typeof PeliculasListComponent | typeof PeliculasFooterComponent | typeof“C:/ UwAmp / www / curso-angu ...”不能分配给'Type | any []'类型 . 输入'typeof'C: /UwAmp/www/curso-angular/app/components/contacto.component“'不能分配给'Type | any []' . 输入'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):error TS2345:类型'的参数({path:string; name:string; component: typeof PeliculasListComponent; useAsDefault:boolean; } ...'不能分配给'RouteDefinition []'类型的参数 . 输入'{path:string; name:string; component:typeof PeliculasListComponent; useAsDefault:boolean; } ...'不能赋值为'RouteDefinition' . 输入'{path:string; name:string; component:typeof“C:/ UwAmp / www / curso-angular / app / components / contac ...”不能分配给'RouteDefinition'类型 . 属性'component'的类型是不兼容的 . 输入'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" ;
}
你有什么想法如何解决它?谢谢!!
1 回答
您最有可能使用角度的过期版本候选版本,如评论中所述 . 因为根据最新文档 in the component decorator 有 no directives 属性:
https://angular.io/docs/ts/latest/api/core/index/Component-decorator.html
从angular.io的指南开始,有很多例子 .
否则从角度种子项目开始,配置所有内容:
https://github.com/angular/angular-seed
从angular直接尝试本指南,它涵盖了您开始所需的几乎所有内容:
https://angular.io/docs/ts/latest/guide/router.html