I recently developed a service called SecurityService to handle authentication. Check out the code for this service below:
import { Injectable } from '@angular/core';
@Injectable()
export class SecurityService {
items: any[];
constructor() {
this.items = [
{ name: 'User 1' },
{ name: 'User 2' },
{ name: 'User 3' }
];
}
getItems() {
return this.items;
}
}
To implement and use this service, I created a simple page as well.
import { Component } from '@angular/core';
import { SecurityService } from '../services/security.service'
@Component({
selector: 'test-page',
template: require('./test/test.page.html'),
providers: [SecurityService]
})
export class TestPage {
items: any[];
constructor(private securitySvc: SecurityService) {
this.items = securitySvc.getItems();
}
}
However, upon loading the page, I encountered an error stating "No provider is given for SecurityService!". After extensively researching this issue, I haven't been able to find a solution yet.
If you need further information to assist in resolving this problem, please let me know.
Your help and insights are highly valued.
- sroye98