I've got problem with loading nativescript app using angular2 and typescript. I'm trying to solve for long time. What i have is:
list.service.ts
import { ItemListApi } from '../sdk/services/custom/ItemList';
import { ItemList } from '../sdk/models/ItemList';
@Injectable()
export class ListService {
items: Observable<Array<Item>>;
public grocery: Grocery = new Grocery('', '');
private listModel: ItemList = new ItemList();
constructor(private itemListApi: ItemListApi,
private authModelApi: AuthModelApi,
private loginCredentials: LoginCredentials) {
}
addItems(list: ItemList) {
let uid;
uid = this.loginCredentials.getUserId();
return this.itemListApi.create({
"name": list.name,
"userid": uid
});
};
}
module.ts
@NgModule({
imports: [
CommonModule,
FormsModule,
RouterModule
],
declarations: [
LoginComponent,
ListComponent
],
providers: [
LoginService,
ListService,
LoginCredentials,
HeroActions,
HeroService
],
exports: [
LoginComponent,
ListComponent
]
})
All the time I'm getting error message saying "No provider for ItemListApi" ... actually ItemListApi is from my loopback nativescript sdk. can someone help me spot that small issue with my code?
Add
ItemListApi
into yourapp.module.ts
's provider list:In reply to what Nick said, he cant add it as a provider in the ts file he's in as he is using
@Injectable
not@Component