摘要: 1.在服务中引入组件 在src/app/services/AppService.ts文件引入组件 import { Injectable } from '@angular/core'; 并注入服务 @Injectable({ providedIn: 'root' }) @injectable 一般用 阅读全文
posted @ 2020-10-22 15:36 站在巨人的肩膀上1 阅读(156) 评论(0) 推荐(0)
摘要: function getInfo(name:string,age?:number):string{ if(age){ return `${name} ${age}` }else{ return `${name} 年龄保密` } } 阅读全文
posted @ 2020-10-22 14:42 站在巨人的肩膀上1 阅读(241) 评论(0) 推荐(0)
摘要: 按快捷键ctrl+p可以弹出一个小窗,在上面的输入框输入文件名,下拉框点击一个文件 阅读全文
posted @ 2020-10-22 11:35 站在巨人的肩膀上1 阅读(1169) 评论(0) 推荐(0)
摘要: #重定向路由 :在用户访问一个特定的地址时,将其重定向到另一个指定的地址 // 路由重定向:下面的代码意思是:当访问一个空字符串的路径时,给重定向到home路由上 {path: '', redirectTo: '/home', pathMatch: 'full'}, 阅读全文
posted @ 2020-10-22 11:13 站在巨人的肩膀上1 阅读(275) 评论(0) 推荐(0)
摘要: angular创建一个默认带路由的项目 1.创建项目命令 ng new angualrdemo08 --skip-install 2.创建需要的组件 ng g component homeng g component newsng g component newscontent 3.找到app-ro 阅读全文
posted @ 2020-10-22 11:04 站在巨人的肩膀上1 阅读(95) 评论(0) 推荐(0)