Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

EXCEPTION: No provider for UserData! (LoginPage -> UserData)

$
0
0

@infoproducts wrote:

Hi guys,

I'm banging my head against a wall here, hoping you can help. I'm not sure if I've run into a bug, it's a setup issue or if I misunderstood something.

The error I'm getting when running the app is:

EXCEPTION: No provider for UserData! (LoginPage -> UserData)

I have imported UserData in both my app.ts and login.ts, and also included it in @App decorator providers array, which to my understanding is the only place I should define it as a provider to make sure I work with the same instance app-wide.

I've stripped the code way down to the smallest example I could come up with and still have the error occur.

Any idea what's going on?

app/app.ts:

import {App} from 'ionic-angular';
import {UserData} from './providers/user-data';
import {LoginPage} from './pages/login/login';

@App({
	template: '<ion-nav [root]="rootPage"></ion-nav>',
	providers: [UserData]
})
export class MyApp {

	public rootPage: any = LoginPage;

	public constructor(protected userData: UserData) {

	}

}

app/pages/login/login.ts:

import {Page} from 'ionic-angular';
import {UserData} from '../../providers/user-data';

@Page({
	templateUrl: 'build/pages/login/login.html'
})
export class LoginPage {

	public constructor(protected userData: UserData) {

	}

}

app/providers/user-data.ts:

import {Injectable} from 'angular2/core';

@Injectable()
export class UserData {

	public constructor() {

	}

}

Ionic info

bash-3.2$ ionic info

Your system information:

Cordova CLI: 6.0.0
Gulp version:  CLI version 3.9.1
Gulp local:   Local version 3.9.1
Ionic Version: 2.0.0-beta.3
Ionic CLI Version: 2.0.0-beta.22
Ionic App Lib Version: 2.0.0-beta.12
ios-deploy version: 1.8.5
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v4.4.0
Xcode version: Xcode 7.3 Build version 7D175

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles