
angular入门
快速入门angular
MIKE-zi
单片机 MCU ECU C语言,汇编软件工程师,IOS objective-c swift 研发工程师 前端开发H5,javaScript,typescript 前端三大框架 vue , react , angular ,微信原生小程序开发,taro跨平台小程序开发
展开
-
angular 路径参数和查询参数
总结一下路径参数和查询参数,为了方便大家对比观察 写在一起方便对比路径参数的配置--查询参数的配置{ path: ':tabLink',component: HomeDetailComponent,}{path: 'home',component: HomeContainerComponent,}路径参数的跳转--查询参数的跳转1.<a [routerLink]="['/home',tablink]"></a>2.this.router.navig原创 2022-04-27 17:45:47 · 964 阅读 · 0 评论 -
Angular 子路由及动态路由
路由的模块写法_MIKE-zi的博客-优快云博客首先参考上篇文章angular 路由基础_MIKE-zi的博客-优快云博客1.首先根节点 app-routing.module.tsconst routes = [{ path: 'home', component: HomeContainerComponent}]@NgModule({ /** * 根路由使用 `RouterModule.forRoot(routes)` 形式。 * 而功能模块中的路由模块使用 `outerModule.forChild(原创 2022-04-27 17:17:15 · 1722 阅读 · 0 评论 -
路由的模块写法
首先参考上篇文章angular 路由基础_MIKE-zi的博客-优快云博客1.首先根节点 app-routing.module.tsconst routes = [{ path: 'home', component: HomeContainerComponent}]@NgModule({ /** * 根路由使用 `RouterModule.forRoot(routes)` 形式。 * 而功能模块中的路由模块使用 `outerModule.forChild(routes)` 形式。 * 启用路由的 de原创 2022-04-27 16:43:49 · 686 阅读 · 0 评论 -
angular 路由基础
1.首先根节点 app-routing.module.tsconst routes = [{ path: 'home', component: HomeContainerComponent}]@NgModule({ /** * 根路由使用 `RouterModule.forRoot(routes)` 形式。 * 而功能模块中的路由模块使用 `outerModule.forChild(routes)` 形式。 * 启用路由的 debug 跟踪模式,需要在根模块中设置原创 2022-04-27 16:36:11 · 644 阅读 · 0 评论 -
angular 脏值检测基础流程
脏值检测需要我们知道的1.单项数据流,从根节点检查到当前页面节点2.脏值检测时候的声明周期更新dom以后 脏值检测需要走两次。下面我们配置一个demo演示。首先配置我们需要的demorouting里面路径配置const routes: Routes = [ { path: 'home', component: HomeContainerComponent, }, { path: 'change-detection', path..原创 2022-04-26 17:45:41 · 787 阅读 · 0 评论 -
angular拦截器的使用
引入拦截器 ngModule中引入拦截器@NgModule({ declarations: [AppComponent], imports: [ ], providers: [ { provide: HTTP_INTERCEPTORS, useClass: NotificationInterceptor, multi: true }, ], bootstrap: [AppComponent]})使用方法1 拦截修改请求头原创 2022-01-26 17:35:02 · 1327 阅读 · 0 评论 -
angular 网络请求HttpClient的使用
使用方法类似服务,就是引入之后直接注入,只不过不用providers引入,使用module的方式引入@NgModule({ declarations: [AppComponent], imports: [ HttpClientModule, ],})使用的地方:import { HttpClient } from '@angular/common/http';@Injectable({ providedIn: 'root'})export class Hom原创 2022-01-26 17:03:32 · 1283 阅读 · 0 评论 -
angular核心概念快速入门
1.指令 directive指令就像是属性 需要宿主元素 改变宿主元素的样式 appGridItemImage appGridItemTitle <img appGridItemImage="2rem" [src]="item.icon" alt="" /> <span appGridItemTitle="0.6rem" class="title">{{ item.title }}</span>详细参考anglar指令的使用_lee727n的博客-CSD原创 2022-01-24 10:57:02 · 327 阅读 · 0 评论 -
angular 服务 .service.ts
首先理解一下angular的服务的本质就是依赖注入 我们写在一个ts文件中 其实service就是一个Injector@Injectable()class Product { constructor( private name: string, private model: string, private color: string, private price: number, private type: string ) { }}export原创 2022-01-24 10:41:32 · 1202 阅读 · 0 评论 -
anglar指令的使用
指令其实就像是自己给组件添加的一个属性使用的地方 .html中 <span appGridItem *ngFor="let item of channels"> <img appGridItemImage="2rem" [src]="item.icon" alt="" /> <span appGridItemTitle="0.6rem" class="title">{{ item.title }}</span>原创 2022-01-24 10:22:48 · 328 阅读 · 0 评论 -
angular 投影概念
投影的概念 就是组件里面的ng-content部分 可以被组件外部包裹的元素替代。 <ng-content select="[appGridItem]"></ng-content>例如,我们现在有个组件 <app-horizontal-grid> <span appGridItem *ngFor="let item of channels"> <img appGridItemImage="2rem" [src]="原创 2022-01-24 10:12:40 · 178 阅读 · 0 评论 -
angular 管道pipe
使用的地方 模板.html<p> {{ date | appAgo }}</p>使用的地方 .ts this.date = this.minusMonths(new Date(), 24); minusMonths(date: Date, months: number) { const result = new Date(date); result.setMonth(result.getMonth() - months); re原创 2022-01-24 10:02:47 · 453 阅读 · 0 评论 -
angular中括号的原理[]
angular中括号的意义,还是通过我们之前封装的tabbar来分析<app-scrollable-tab [menus]="topMenus" backgroundColor="green" titleColor="#fff" tilteActiveColor="yellow" (tabSelected)="handleTabSelected($event)"></app-scrollable-tab>组件内部接收background的属性 接收颜色的字符串.原创 2021-07-22 18:40:18 · 525 阅读 · 0 评论 -
angular样式绑定
总结angular中的几种样式绑定方法,先上代码,自定义组件tabbar<ul [ngStyle]="{ 'background-color': backgroundColor }"> <li *ngFor="let menu of menus; let i = index ; let even = even; let odd = odd" [ngClass]="{ even: even, odd: odd }" > <br>原创 2021-07-22 17:45:50 · 911 阅读 · 1 评论 -
angular组件传值 输入输出
还是利用tabbar来介绍,上代码<app-scrollable-tab [menus]="topMenus" (tabSelected)="handleTabSelected($event)"></app-scrollable-tab>组件内部js selectedIndex = -1; @Input() menus: TopMenu[] = []; @Output() tabSelected = new EventEmitter(); co原创 2021-07-21 17:42:20 · 241 阅读 · 0 评论 -
angular ngif指令
还是用topbar演示 ngif的使用 上代码<ul> <li *ngFor="let menu of menus; let i = index"> <a href="#" [class.active]="i === selectedIndex" (click)="handleSelection(i)"> {{ menu.title }} </a> <span class="indicator" *ngIf=原创 2021-07-21 17:25:50 · 486 阅读 · 0 评论 -
angular重要指令ngfor
通过一个顶部导航栏看下一ngfor的使用。上代码<ul> <li *ngFor="let menu of menus; let i = index let one = first let final = last"> <a href="#" [class.active]="i === selectedIndex" [class.first]='one' [class.final]='final' (click)="selectedIndex = i原创 2021-07-21 16:26:39 · 995 阅读 · 0 评论 -
packge.json版本依赖详解
"dependencies": { "@angular/animations": "~8.0.0", "@angular/common": "~8.0.0", "@angular/compiler": "~8.0.0", "@angular/core": "~8.0.0", "@angular/forms": "~8.0.0", "@angular/platform-browser": "~8.0.0", "@angular/platform-b...原创 2021-05-12 19:43:05 · 222 阅读 · 0 评论 -
angular项目结构介绍
一张图看懂angular项目结构原创 2021-05-12 19:35:48 · 319 阅读 · 0 评论 -
angular项目搭建 脚手架
1.安装node.js 直接官网下载https://nodejs.org/en/2.安装之后查一下 node 版本npm -v3.装好node 就有了npm npm中可以找到各种框架 网址:https://www.npmjs.com/package/@angular/cli4.安装angular cli 上面网址中 可以直接拷贝命令npm install -g @angular/cli5.如果网速慢 讲npm替换为cnpmnpm install cnpm -g --reg.原创 2021-03-02 14:34:45 · 406 阅读 · 1 评论