Angular基础知识学习(二)

服务 创建服务之后,我们在 StorageService.service.ts 中定义一个测试方法: export class StorageService { constructor() { } test() { alert('调用服务方法'); } } 复制代码 我们重新建立一个 home 组件,来测试服务调用。 <p>home works!</p> <button (click)="getSe...