我正在使用离子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) 我正在使用离子2.
我需要获取上一页的名称.
这是我的代码.
@ViewChild(Nav) nav:Nav
constructor() {
this.nav_app.viewDidEnter.subscribe(
view => console.log("Current opened view is : " + view.name);
)
}
Run Code Online (Sandbox Code Playgroud)
我还在
Current opened view is : t
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得以前的页面名称.
请告诉我,
谢谢
我使用ionic2带FCM.
我在应用运行时收到通知.
我需要在应用程序运行时收到通知.
我怎样才能做到这一点 ?
我正在使用离子3.
这是我的模板
<ion-slides autoplay="5000" loop="true" speed="500" class="slides" pager="true">
<ion-slide *ngFor="let Image of PImage">
<img src="{{Image.URL}}" alt="Product Image">
</ion-slide>
</ion-slides>
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个错误
TypeError: Cannot read property 'hasAttribute' of undefined
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
请告诉我,
谢谢
我正在使用角度2选择。
我正在使用formControlName。
<form class="edit" [formGroup]="addcameraForm" (ngSubmit)="onSubmit(addcameraForm.value)" class="form-horizontal">
<div class="albumname">
<label for="input01">Select user</label>
<ng-select style="color:#000;"
formControlName="selectMultiple"
[options]="options"
[multiple]="true"
placeholder="Select Assets">
</ng-select>
</div>
<div class="form-group">
<div class="col-sm-10">
<button class="btn btn-success btn-auth" [disabled]="!addcameraForm.valid">Add Camera</button>
</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
这是我的组件。
ngOnInit() {
this.addcameraForm = this.fb.group({
ACCESS_USERS : this.fb.array([]),
APART_ID:[''],
CAMERA_ACCESS_CODE:[''],
CAMERA_ACCESS_URL: [''],
CAMERA_CODE: [''],
CAMERA_NAME: [''],
CAMERA_PASSWORD:[''],
CAMERA_STATUS:[''],
CAMERA_USERNAME:[''],
selectMultiple:['']
});
}
Run Code Online (Sandbox Code Playgroud)
我得到这个错误
Error: There is no FormControl instance attached to form control element with name: 'selectMultiple'
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题。
请告诉我,
这是我的数组
arr=[
{
date:'2017-06-14 14:03:49'
},
{
date:'2017-04-20 10:25:32'
},
{
date:'2017-06-02 15:57:16'
},
{
date:'2017-06-02 17:52:05'
},
{
date:'2017-06-02 21:47:13'
},
{
date:'2017-06-14 14:01:31'
}
]
Run Code Online (Sandbox Code Playgroud)
我需要按日期对数组进行排序。
我怎样才能做到这一点,
请告诉我,
谢谢
我正在使用ionic2.
这是我的模板
<ion-slides autoplay="5000" loop="true" speed="500" pager="true">
<ion-slide class="slider1">
<h1>My <span>Neighbours</span></h1>
<p>My Neighbours is a directory of people who live in the building and have chosen to</p>
<div class="homepeople">
<div class="home"></div>
<div class="people"></div>
</div>
</ion-slide>
<ion-slide class="slider2">
<h1>CCTV <span>Monitoring</span></h1>
<p>Residents/Managers can view selected CCTV</p>
<div class="iconholder">
<img src="./assets/images/white CCTV Monitoring.svg" alt="Image">
</div>
</ion-slide>
<ion-slide class="slider3">
<h1>Emergency</h1>
<p>Security / Reception / Police / Ambulance / Fire</p>
<div class="iconholder">
<div class="iconholder-blk">
<img src="./assets/images/white emergency icon.svg" alt="Image">
</div>
<div class="iconholder-blk">
<img src="./assets/images/white Alarm.svg" …Run Code Online (Sandbox Code Playgroud) ionic2 ×6
angular ×3
typescript ×2
android ×1
arrays ×1
autocomplete ×1
ionic3 ×1
javascript ×1