上一页 1 ··· 4 5 6 7 8
摘要: angular中 父组件调用子组件的方法 -- 使用 @ViewChild 装饰器修饰子组件,获取方法,调用 除此之外 ViewChild 还可以获取 DOM ,操作 DOM , 详见: https://www.cnblogs.com/monkey-K/p/11567098.html 1. html 阅读全文
posted @ 2019-09-22 13:21 monkey-K 阅读(3844) 评论(0) 推荐(0) 编辑
摘要: ngAfterViewInit(): void { // DOM 加载完成的生命周期函数, 在此处获取 DOM let dom2: any = document.getElementById('dom2') console.log(dom2) dom2.style.color = 'blue' } 阅读全文
posted @ 2019-09-22 13:15 monkey-K 阅读(538) 评论(0) 推荐(0) 编辑
摘要: 一. canActive 使用场景:导航栏某个标签,如用户设置页面,只有登录才可以查看,不登录则点击无效 说明: canActive--是否能调用当前路由 实现: 1. 创建路由守卫类 import { CanActivate } from '@angular/router' export clas 阅读全文
posted @ 2019-09-10 10:59 monkey-K 阅读(509) 评论(0) 推荐(0) 编辑
摘要: 1. 路由跳转方式一: /路由?id='001' 方式 -- queryParams 方式 路由配置:{ path: 'details', component: bookDetailsComponent } a. 指令跳转: <a [routerLink]="['/details']" [query 阅读全文
posted @ 2019-09-05 17:49 monkey-K 阅读(8013) 评论(0) 推荐(1) 编辑
摘要: 1. 新建一个app.routing.module.ts 文件,可以手动添加也可以命令生成 (ng generate module app-routing --flat --module=app) import { NgModule } from '@angular/core'; import { 阅读全文
posted @ 2019-09-03 20:06 monkey-K 阅读(618) 评论(0) 推荐(0) 编辑
摘要: 1. 自定义指令 - @directive import { Component, Directive, HostListener, ElementRef } from '@angular/core' @Directive({ selector: '[input-trim]', host: { '( 阅读全文
posted @ 2019-09-02 22:42 monkey-K 阅读(3773) 评论(0) 推荐(0) 编辑
摘要: 1. angular8.1.1 package.json { "name": "angular-demo", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": 阅读全文
posted @ 2019-09-01 17:34 monkey-K 阅读(1257) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8