import { LoggingService } from "./logging.service";
export class AccountsService {
constructor(private loggingService: LoggingService) {}
accounts = [{
name: 'Master Account',
status: 'active'
},
{
name: 'Testaccount',
status: 'inactive'
},
{
name: 'Hidden Account',
status: 'unknown'
}
];
addAccount(newAccount: {name: string, status: string}) {
this.accounts.push(newAccount);
this.loggingService.loggingStatusChange(newAccount.status);
}
updateStatus(id: number, status: string) {
this.accounts[id].status = status;
this.loggingService.loggingStatusChange(status);
}
}
答案 0 :(得分:0)
只要您不对应用程序可见的任何组件进行注入或使用 AccountsService
,很好(我的意思是说可见的是@NgModule()
类装饰器中是否“导入/声明/提供了”)。
如果您已经在某个地方使用过AccountsService
并且您的应用没有对您大吼大叫 error
。然后,它可能会在您应用程序中的@NgModule({})
中提供。否则它将无法正常工作。