随笔分类 -  Angular

Angular入门学习记录
摘要:开始我们新建项目的步骤是: ng new demo --skip-install cnpm install ng serve 主要是用了cnpm的原因,替换成npm就ok了 1,先删除(rd /s /Q node_modules) 2,npm install 阅读全文
posted @ 2020-07-19 19:46 风子磊 阅读(345) 评论(0) 推荐(0)
摘要:一,内置模块 二、Angular自定义模块当我们项目比较小的时候可以不用自定义模块。但是当我们项目非常庞大的时候把所有的组件都挂载到根模块里面不是特别合适。所以这个时候我们就可以自定义模块来组织我们的项目。并且通过Angular自定义模块可以实现路由的懒加载。 1,创建模块 ng g module 阅读全文
posted @ 2020-07-07 09:12 风子磊 阅读(263) 评论(0) 推荐(0)
摘要:一,get传值 传 <ul *ngFor="let l of list;let ss=index;"> <li><a routerLink="/newsDetail" [queryParams]="{aid:l.id}">{{l.content}}</a></li> </ul> 接收 import 阅读全文
posted @ 2020-07-06 10:18 风子磊 阅读(232) 评论(0) 推荐(0)
摘要:一,概述 路由就是根据不同的url地址,动态的让根组件挂载其他组件来实现一个单页面应用 二,使用 1,创建项目时注意选择创建路由--yes 2,在app-routing.module.ts中引入需要配置路由的组件,然后声明访问路径 import { HomeComponent } from './c 阅读全文
posted @ 2020-07-05 21:16 风子磊 阅读(414) 评论(0) 推荐(0)
摘要:一、Angular get请求数据 Angular5.x以后get, post和和服务器交互使用的是HttpClientModule模块。 1、在app.module.ts中引入HttpClientModule并注入 import {HttpClientModule} from '@angular/ 阅读全文
posted @ 2020-07-05 10:50 风子磊 阅读(3651) 评论(0) 推荐(0)
摘要:一,父组件给子组件传值 1,父组件调用子组件的时候传入数据 <app-header [msg]="msg"></app-header> 2,子组件引入Input模块 import { Component, OnInit ,Input } from '@angular/core'; 3,子组件中@In 阅读全文
posted @ 2020-07-04 15:56 风子磊 阅读(524) 评论(0) 推荐(0)
摘要:一,引入模块 import {FormsModule} from "@angular/forms"; 二,js中定义绑定数据 public user:any={ username:'', sex:'1', cityList:['北京','上海','深圳'], city:'北京', hobby:[ { 阅读全文
posted @ 2020-07-04 12:06 风子磊 阅读(872) 评论(0) 推荐(0)
摘要:一,先来一张盗的图 以上就是大概目录结构,我们编写代码主要在app这个文件夹下 根模块简介app.module.ts 其中app.component.css,app.component.html,app.component.ts组成根组件,项目启动后就把根组件添加到index.html页面中,渲染到 阅读全文
posted @ 2020-07-04 08:52 风子磊 阅读(230) 评论(0) 推荐(0)
摘要:一,Angular介绍 Angualr是谷歌开发的一款开源的web前端框架,诞生于2009年,由Misko Hevery人创建,后为Google所收购。是一款优秀的前端JS框架,已经被用于Google的多款产品当中,根据项目数统计angular (1.x 、2.x、4.x. 5.x,6.x、7.x 阅读全文
posted @ 2020-07-03 17:34 风子磊 阅读(111) 评论(0) 推荐(0)