Typescript编译器错误 - 提供的参数与调用目标的任何签名都不匹配

时间:2015-11-16 10:15:58

标签: angular typescript firebase

Typescript编译器 - 提供的参数与调用目标的任何签名都不匹配。

我正在创建一个带有打字稿的angular2应用程序。 当我将实例设置为firebase时,它在git bash命令行中给出了这个错误:“提供的参数与调用目标的任何签名都不匹配”。

它抱怨这行代码说:

this.data = new AngularFire(新Firebase('https://markng2.firebaseio.com/users'));

这是app.ts文件的代码:

   import {Component, View, bootstrap, bind, provide} from 'angular2/angular2';
   import {Router, ROUTER_BINDINGS, RouterOutlet, RouteConfig, RouterLink, ROUTER_PROVIDERS, APP_BASE_HREF} from 'angular2/router';
   import {Injectable} from 'angular2/angular2';
   import {HTTP_PROVIDERS, Http, Headers} from 'angular2/http';

   import {Todo} from './components/todo/todo';
   import {About} from './components/about/about';
   import {AuthService} from './authService';
   import {EnvironmentService} from './environmentService';

   import {AngularFire, FirebaseArray} from '../firebase/angularfire';

   @Component({
           selector: 'app'
   })

   @View({
       template: `
           <div class="container">
               <nav>
                <ul>
                    <li><a [router-link]="['/Home']">Todo</a></li>
                    <li><a [router-link]="['/About']">About</a></li>
                   </ul>
               </nav>
            <router-outlet></router-outlet>
           </div>
        `,
       directives: [RouterOutlet, RouterLink]
   })

   @RouteConfig([
    { path: '/', redirectTo: '/home' },
    { path: '/home', component: Todo, as: 'Home' },
    { path: '/about', component: About, as: 'About' }
   ])

   @Injectable()
   export class AppComponent {
       store:FirebaseArray;
       data: AngularFire;

       constructor(_router: Router, _authService: AuthService){ 

           //Firebase setup - Here the line below seems to be the issue???:
           this.data = new AngularFire(new Firebase('https://markng2.firebaseio.com/users'));
           this.store = this.data.asArray();        

           _router.subscribe((val) => {     

               _authService.isUserLoggedIn().then((success) => {    
                   if(!success){                    
                       _router.navigate(['/About']);
                   }else{
                       _authService.getSpotifyData().then((success) => {    
                           console.log(success);                        
                       });  
                   } 
               });  
           })
       }
   }

   bootstrap(AppComponent, [ROUTER_PROVIDERS, provide(APP_BASE_HREF, {useValue: '/'}), HTTP_PROVIDERS, AuthService, EnvironmentService]);

这是Git Bash Command错误:

enter image description here

1 个答案:

答案 0 :(得分:2)

更新: We are working on AngularFire2 right now

我认为这里的混乱是现在没有AngularFire for Angular 2。

目前的AngularFire 1.0+与Angular 2不兼容。仅限AngularJS 1.2+。

This AngularFire for Angular 2是我为this presentation撰写的内容。它没有得到官方支持。

虽然目前还没有与Firebase和Angular 2进行官方集成,但由于zone.js的神奇之处,Firebase SDK完美运行。