简体   繁体   中英

“Has no exported member ionicBootstrap” (ionic2 Typescript)

I have such an error: has no exported member ionicBootstrap.

ionicBootstrap was introduced in ionic-angular 2.0.0-beta.8. But I upgrade to the 2.0.0-beta.32 and the error is still remains. What will it can be?

I am new to Ionic and angular, but I think I have figured out this provider issue. I was following this article to make a LocalState provider to allow pages to share information between each other in an Ionic2 app. http://www.joshmorony.com/an-in-depth-explanation-of-providers-in-ionic-2/

I ran into the ionicBootstrap issue mentioned in this question. According to this source, 'You do not need ionicBootstrap anymore since rc0.' https://forum.ionicframework.com/t/no-exported-member-ionicbootstrap/66721

I created a provider with

ionic g provider LocalState

I added the following to app.module.ts:

import { LocalState } from '../providers/local-state';

...

@NgModule({
  declarations: [
    MyApp,
    Page1,
    Page2
  ],
  imports: [
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    Page1,
    Page2
  ],
  providers: [
    LocalState
  ]
})

In app.component.ts and in each page's .ts file I added:

import { LocalState } from '../providers/local-state';

and added LocalState to the constructor:

constructor(public platform: Platform, public localState: LocalState)

I could then read the members of LocalState in the page's .html file with:

{{localState.<insert member name>}}

I could update a LocalState member in methods in the page's .ts file. For testing I called localState.setMember() in one page's constructor and other pages could read the updated value.

I had this problem as well. It turned out that I had two typings ionic and cordova-ionic which appeared to be outdated. I installed the starter to see if I had the same problem did not. The starter project did not have those typings so I removed them and ran typings prune . After my project rebuilt the error was gone. It looks like the typings are included in the ionic-angular package from npm.

Also from the screenshot it posted it looks like you still have 2.0.0-beta.7 . Try running npm install --save @2.0.0-beta.8

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM