小编Muh*_*lah的帖子

无法读取未定义的属性"native-element"

我正在使用离子2.

我需要获取HTML元素值.

实际上,我使用了viewchild.

这是我的html模板代码

<div class="messagesholder" *ngFor="let chat of chatval | orderby:'[date]'; let last = last">
       {{last ? callFunction() : ''}} 

   <div *ngIf="chat.sender == currentuser || chat.receiver == currentuser">    
     <p class="chat-date"  id="abc" #abc>{{chat.date | amDateFormat:'LL'}}</p>                 
              {{checkdate()}}                         
   </div>
Run Code Online (Sandbox Code Playgroud)

chat.date值是firebase值.我访问这个元素.但我没有得到元素的价值.

这是我的组件

import {Component, ElementRef,ViewChild, OnInit} from '@angular/core';

    export class ChatPage   {
      @ViewChild(Content) content: Content;
      @ViewChild('abc')abc: ElementRef;
       constructor(){}

      ngAfterViewInit(){

       console.log("afterinit");
       console.log(this.abc.nativeElement.value);

      }
    }
Run Code Online (Sandbox Code Playgroud)

我引用了这个链接如何在组件模板中选择一个元素?

我试过很多方面.

但是我收到了这个错误

Cannot read property 'nativeElement' of undefined.
Run Code Online (Sandbox Code Playgroud)

typescript ionic2 angular

17
推荐指数
2
解决办法
5万
查看次数

电子打印中构建的角度应用程序 div 显示空白窗口

我开发了一个角度应用程序,然后我在电子中构建了该应用程序。该应用程序工作正常,但是当我单击按钮打印特定的 div 时,它会打开一个电子的空白窗口。我用ngx-print图书馆。它适用于角度发球,但电子构建有问题。

<button class="btn btn-raised mr-1 shadow-z-2 btn-success"  
printSectionId="print-section" ngxPrint>
   print
</button>

<div id="print-section"> Print This</div>
Run Code Online (Sandbox Code Playgroud)

electron angular

4
推荐指数
1
解决办法
2115
查看次数

使用角度从选项下拉列表中过滤/搜索

我有带有复选框和下拉列表选项的多选下拉菜单。我想对下拉选项实现运行时/动态过滤搜索。我能够实现过滤搜索,但不能在运行时实现。

this.options = [{ value: "Small", selected: false },
        { value: "Medium", selected: false},
        { value: "Large", selected: false }]

filterUsers() {
        let filterUsers= this.options.filter(item => item.value === this.selectedUser);
        if (filterUsers.length > 0) {
            this.options = filterUsers;
        }
 }    
        console.log(filterUsers);
    }

HTML

<input type = "text" [(ngModel)]="selectedUser" (input) = "filterUsers()">
Run Code Online (Sandbox Code Playgroud)

如何实现动态过滤搜索?

javascript typescript angular

4
推荐指数
1
解决办法
4万
查看次数

标签 统计

angular ×3

typescript ×2

electron ×1

ionic2 ×1

javascript ×1