0

i'm trying to create plunker that uses routes in angular2 (beta.17 version), for some reason when i trying to put ROUTER_PROVIDERS as dependencies of "App" in "main.ts"

    //main entry point
import {bootstrap} from '@angular/platform-browser-dynamic';
import {provide, bind} from 'angular2/core';
import {ROUTER_PROVIDERS, ROUTER_BINDINGS, LocationStrategy, HashLocationStrategy} from 'angular2/router';

import {App} from './app';

bootstrap(App, [ROUTER_PROVIDERS])//<-here
  .catch(err => console.error(err));  

i'm getting this error: angular2-polyfills.js:349 Error: Invalid provider - only instances of Provider and Type are allowed, got: object Object

plunk

What am i missing?

Thanks

happyZZR1400
  • 2,387
  • 3
  • 25
  • 43

3 Answers3

1

According to changelog: annotation imports came with rc.0. So you are using beta17 but your setup is for rc.0-1.

Source: https://github.com/angular/angular/blob/master/CHANGELOG.md

eko
  • 39,722
  • 10
  • 72
  • 98
  • sorry, but where in the plunk it mentioned "annotation imports came with rc.0."? is it somewhere in plunk? – happyZZR1400 May 16 '16 at 07:04
  • @happyZZR1400 no not in the plunk. I said in the changelog. See the changelog for rc.0 =>https://github.com/angular/angular/blob/master/CHANGELOG.md#200-rc0-2016-05-02. It says: To import various symbols please adjust the paths in the following way: angular2/core -> @angular/core... – eko May 16 '16 at 07:13
0

you are mixing the imports of angular2 RC.0 and angular2 beta 17, few mistakes you have done take a look at them: -

  1. you havn't ser base href set this in the index.html like this-

    <base href="/"></base>
    
  2. in main.ts correct import like this

    import {bootstrap} from 'angular2/platform/browser';

  3. in app.ts make some changes like this

    import {Component} from 'angular2/core'

For more clearification on import have a look at this -

here is your working plunker Working Plunker

Community
  • 1
  • 1
Pardeep Jain
  • 84,110
  • 37
  • 165
  • 215
0

This may help. The new router for Angular 2 rc1.

https://angular.io/docs/ts/latest/guide/router.html

  • A link to a potential solution is always welcome, but please add [context around the link](http://meta.stackoverflow.com/a/8259/169503) so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. Take into account that being barely more than a link to an external site is a possible reason as to [Why and how are some answers deleted](http://stackoverflow.com/help/deleted-answers)? – Raju May 22 '16 at 09:21