Runtime Error
Uncaught (in promise): Error: No provider for QuotesService! Error: No provider for QuotesService! at injectionError (http://localhost:8100/build/vendor.js:1590:86) at noProviderError (http://localhost:8100/build/vendor.js:1628:12) at ReflectiveInjector_.throwOrNull (http://localhost:8100/build/vendor.js:3129:19) at ReflectiveInjector.getByKeyDefault (http://localhost:8100/build/vendor.js:3168:25) at ReflectiveInjector.getByKey (http://localhost:8100/build/vendor.js:3100:25) at ReflectiveInjector.get (http://localhost:8100/build/vendor.js:2969:21) at AppModuleInjector.NgModuleInjector.get (http://localhost:8100/build/vendor.js:3937:52) at resolveDep (http://localhost:8100/build/vendor.js:11398:45) at createClass (http://localhost:8100/build/vendor.js:11262:32) at createDirectiveInstance (http://localhost:8100/build/vendor.js:11082:37)
hello everyone…i am newbie in ionic, and i got this error…i had already find all of forum about this prob, but i still cant find what should i do… kindly help!!!
here is my code
this is data/quote.ts
import { Quote } from '../data/quote.interface';
export class QuotesService{
private favoriteQuotes: Quote[] = [];
addQuoteToFavorites(quote:Quote){
this.favoriteQuotes.push(quote);
}
removeQuoteFromFavorites(quote:Quote){
}
getFavoriteQuotes(){}
isFavorite(quote:Quote){}
getAllFavoriteQuotes(){}
}
this is my pages/quotes/quotes.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
import { Quote } from '../../data/quote.interface';
import { QuotesService } from '../../services/quotes';
/**
* Generated class for the QuotesPage page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-quotes',
templateUrl: 'quotes.html',
})
export class QuotesPage {
k2quote: Quote[];
constructor(public navCtrl: NavController, public navParams: NavParams, private alertCtrl: AlertController, private quotesService: QuotesService) {
}
ionViewDidLoad(quote) {
console.log('ionViewDidLoad QuotesPage');
}
ngOnInit(){
this.k2quote = this.navParams.get('kquote');
}
klikfav(){
let alert =this.alertCtrl.create({
title:"jadi fav?",
message: 'jadi fav gak ni?',
buttons:[
{
text:"OK",
handler:()=>{
console.log('oke jadi fav deh');
}
},
{
text:'Cancel',
role: 'cancel',
handler:()=>{
console.log('gajadi yahhh');
}
}
]
});
alert.present();
}
onAddQuote(quote: Quote){
this.quotesService.addQuoteToFavorites(quote);
}
}
this is my pages/quotes/quotes.html
<!--
Generated template for the QuotesPage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar>
<ion-title>Quotes</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-card *ngFor="let hquote of k2quote">
<ion-card-header>{{hquote.id}}</ion-card-header>
<ion-card-content>
"{{hquote.text}}"
<br><br>
<p text-right>
-{{hquote.person}}
</p>
</ion-card-content>
<ion-grid>
<ion-row text-right>
<ion-col>
<button ion-button clear small color="blue" icon-start (click)="klikfav(hquote)">
<ion-icon name="star"></ion-icon>
Favorite
</button>
</ion-col>
</ion-row>
</ion-grid>
</ion-card>
</ion-content>