Angular的viewchild在使用的时候报错 undefined

1 检查是否在元素上打上标识 #xxx

2 查看引用元素时的时机 是否在AfterViewInit之后

3 检查元素是否在*ngIf="false"之内

参考:

https://stackoverflow.com/questions/34947154/angular-2-viewchild-annotation-returns-undefined

Angular Viewchild undefined的更多相关文章

  1. Angular ViewChild

    viewchild // 使用方法 git clone https://git.oschina.net/mumu-osc/learn-component.git cd learn-component ...

  2. Angular @ViewChild,Angular 中的 dom 操作

    Angular 中的 dom 操作(原生 js) ngAfterViewInit(){ var boxDom:any=document.getElementById('box'); boxDom.st ...

  3. angular ViewChild ContentChild 系列的查询参数

    官方说明 官方文档 在调用 NgAfterViewInit 回调函数之前就会设置这些视图查询. 元数据属性: selector - 用于查询的指令类型或名字. read - 从查询到的元素中读取另一个 ...

  4. [Angular] @ViewChild read custom directive and exportAs

    For example we have a component: <Card ></Card> And a driective: <Card highlighted> ...

  5. [Angular] ViewChild 'read' option

    It is not clear in the Docs about {read: xx} option for @ViewChild. Based on the Source code, @ViewC ...

  6. [Angular] @ViewChild and template #refs to get Element Ref

    We can use @ViewChild with component: @ViewChild(AuthMessageComponent) message: AuthMessageComponent ...

  7. Angular ViewChild & ViewChildren

    基础 ViewChild ViewChild 装饰器用于获取模板视图中的元素或直接调用其组件中的方法.它支持 Type 类型或 string 类型的选择器,同时支持设置 read 查询条件,以获取不同 ...

  8. AngularJs Angular数据类型判断

    angular.isArray 判断括号内的值是否为数组. 格式:angular.isArray(value); value: 被判断是否为数组的值. ------------------------ ...

  9. Angular - - Angular数据类型判断

    angular.isArray 判断括号内的值是否为数组. 格式:angular.isArray(value); value: 被判断是否为数组的值. ------------------------ ...

随机推荐

  1. 前端入门——day1(简介及推荐书籍和网站)

    写给谁 这篇文章写给想要入门前端或者刚入门前端的小白~如果是已经工作好几年的小伙伴们可以直接跳过这一系列文章啦. 为啥写这篇文章 终于决定给自己挖这个坑了,之前一直没打算写这样的系列文章.回想起自己的 ...

  2. MSSQL 如何导出db所有用户权限创建语句

    use dbgoDECLARE @Database varchar(255),@loginName varchar(255),@roleName varchar(255),@sql nvarchar( ...

  3. functional-page-navigator 组件

    functional-page-navigator 组件:是一个非常强大的组件,用于跳转插件的功能页 functional-page-navigator组件的属性: version:类型 字符串 跳转 ...

  4. React-Native 之 GD (四)使用通知方式隐藏或显示TabBar

    1.GDHalfHourHot.js  发送通知 /** * 近半小时热门 */ import React, { Component } from 'react'; import { StyleShe ...

  5. Laravel 的Artisan 命令学习

    Laravel 的Artisan 命令学习 Artisan 是 Laravel 提供的 CLI(命令行接口),它提供了非常多实用的命令来帮助我们开发 Laravel 应用.前面我们已使用过 Artis ...

  6. loj#6036 编码

    分析 考虑trie+2sat 每次将?=0和?=1的分别插入 插入串时将这个点的选择状态和前缀的选择状态连关系边 注意串结束时建一个新点表示当前串 最后跑2sat即可 代码 #include<b ...

  7. @TableLogic表逻辑处理注解(逻辑删除)

    在字段上加上这个注解再执行BaseMapper的删除方法时,删除方法会变成修改 例: 实体类:    @TableLogic private Integer del;   service层: 调用Ba ...

  8. 014-elasticsearch5.4.3【五】-搜索API【三】复合查询boolQuery、constantScoreQuery、disMaxQuery

    一.概述 复合查询包装其他复合或叶子查询,以组合其结果和分数,更改其行为,或从查询切换到筛选器上下文. 1.1.constantScoreQuery 包含另一个查询但在过滤器上下文中执行的查询.所有匹 ...

  9. 阶段1 语言基础+高级_1-2 -面向对象和封装_14private关键字的作用及使用

    新建一个类Person代表人 创建demo03Person类去调用Person这个类 年龄设置为负数.虽然可以设置为负数.但是这个数值不合理 外部访问这个age就会报错 负数设置不进来.正数也设置不了 ...

  10. linux查找所有文件中某个字符串

    查找目录下的所有文件中是否含有某个字符串 find .|xargs grep -ri "IBM" 查找目录下的所有文件中是否含有某个字符串,并且只打印出文件名 find .|xar ...