在我的page.html表单上,我有一个ion-datetime字段,单击它时,会打开 Ionic 日历以选择所需的日期。我希望它在我的表单打开时显示当前日期。我正在尝试使用下面的代码,但它仍然显示blank字段。
page.html 代码:
<ion-datetime displayFormat="DD/MM/YYYY" name="myDate" [(ngModel)]="myDate"></ion-datetime>
Run Code Online (Sandbox Code Playgroud)
page.ts 代码:
public myDate=new Date();
Run Code Online (Sandbox Code Playgroud)
如何在 HTML 页面上显示当前日期?
简要说明:如果var c = familyArray.includes("Bart");它会返回false 但是否var c = familyArray.includes("Homer");会返回true
我也希望它是真实的Bart,因为它也包含在数组中。
下面是我的数组:
var familyArray = ["Marge", "Homer", ["Bart", "Lisa", "Maggie"]];
var a = familyArray.indexOf("Bart");
var b = familyArray[2][0];
var c = familyArray.includes("Bart");
document.getElementById("demo").innerHTML = c;
console.log(a);
console.log(b);Run Code Online (Sandbox Code Playgroud)
<p id="demo"></p>Run Code Online (Sandbox Code Playgroud)
简要说明:尝试在home.html页面上实现popover控制器.试图按照文档但仍然无法完成.
我在popover.ts旁边创建了页面,home.ts但是当我尝试导入时home.ts,它就是说Cannot find module 'popover'.
我究竟做错了什么 ?
home.ts
import { PopoverController } from 'ionic-angular';
import { PopoverPage } from 'popover';
@Component({})
class MyPage {
constructor(public popoverCtrl: PopoverController) {}
presentPopover(myEvent) {
let popover = this.popoverCtrl.create(PopoverPage);
popover.present({
ev: myEvent
});
}
}
Run Code Online (Sandbox Code Playgroud)
popover.ts
import { Component } from '@angular/core';
import { ViewController } from 'ionic-angular';
@Component({
template: `
<ion-list>
<ion-list-header>Ionic</ion-list-header>
<button ion-item (click)="close()">Learn Ionic</button>
<button ion-item (click)="close()">Documentation</button>
<button ion-item (click)="close()">Showcase</button>
<button …Run Code Online (Sandbox Code Playgroud) 我可以保存一个数组,如下所示:
list: Array<number> = [1, 2, 3];
Run Code Online (Sandbox Code Playgroud)
但我想保存一些更复杂的案例,如:
[{name:"saurabh" , age: 5 , sex:"male"}];
Run Code Online (Sandbox Code Playgroud)
现在我该怎么做?请帮忙
简要说明:我有一个div里面有谷歌地图 iframe 的。单击此 div 时,我想完全更改内部 iframe。我正在尝试使用以下代码实现相同的目标,但它不起作用。
我哪里错了?
主页.html
<div class="sim-row-edit-maps">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2598.0908429283936!2d75.5727857336016!3d31.318772374331786!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x391a5af808690f0f%3A0xc7b0e76486fbe177!2sSapphire+IT+Solutions+Pvt+Ltd!5e0!3m2!1sen!2sin!4v1536835928546" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
</div>
Run Code Online (Sandbox Code Playgroud)
脚本.js
$(".sim-row-edit-maps").click(function(){
alert("maps clicked");
$(this).find('iframe').attr('src', 'https://www.youtube.com/embed/drOnSwo1Ob0');
});
Run Code Online (Sandbox Code Playgroud)
我的代码正在更改scr而我想将整个iframe标签更改为
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d38490.03849859351!2d75.57911957607793!3d31.314034161618853!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x391a5af2e467dd43%3A0x19b51499bc01fdc3!2sTagore+Hospital+%26+Heart+Care+Centre+Private+Limited!5e0!3m2!1sen!2sin!4v1536836365464" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我试图从 Angular 访问 PHP API URL 来发送短信。
如果消息中没有空格,则一切正常,但如果我添加空格,则不会收到任何消息。
下面是我的 PHP 代码:
<?php
header('Access-Control-Allow-Headers:Content-Type,x-prototype-version,x-requested-with');
header('Cache-Control:max-age=900');
include_once("conn.php");
$phno=$_POST['phno'];
$msg=$_POST['msg'];
$final = array();
$msg='Thank you.';
sms($phno,$msg);
$final['status']='success';
$final['message']="Success";
echo json_encode($final);
function sms($phonesms,$msg)
{
//echo 'hello';
$url = 'http://sms.domain.com/Api.aspx?usr=abcapi&pwd=pass123&smstype=TextSMS&to='.$phonesms.'&rout=Transactional&from=SMSACT&msg='.$msg;
echo $url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
}
?>
Run Code Online (Sandbox Code Playgroud)
所以如果$msg='Thank you.';短信不去,如果$msg='Thankyou.';短信去。
我确信我还需要在这里做一些事情 -$url = 'http://sms.domain.com/Api.aspx?usr=abcapi&pwd=pass123&smstype=TextSMS&to='.$phonesms.'&rout=Transactional&from=SMSACT&msg='.$msg;
从数据库获取值后,我试图将它放入一个变量中,但是当我这样做时,它给了我错误:
core.js:6014 ERROR Error: Uncaught (in promise): TypeError: Cannot set property 'userNm' of undefined
TypeError: Cannot set property 'userNm' of undefined
这是我的ts代码:
userNm: string ='';
ngOnInit(){
console.log("trying...");
firebase.firestore().collection(`Students`)
.where("authId", "==", this.userId)
.get()
.then(querySnapshot => {
querySnapshot.forEach(function(doc) {
console.log(doc.data().Name); // OK RESULT IN CONSOLE.LOG,NAME IS String in db.
this.userNm=doc.data().Name; // ERROR HERE
console.log(this.userNm)
console.log(doc.id, " ===> ", doc.data());
});
});
Run Code Online (Sandbox Code Playgroud)
控制台和数据库截图:
javascript typescript ionic-framework angular google-cloud-firestore
如果它是一个文本字段,我可以使用 where 条件获取数据,但是当我尝试对时间戳字段和日期执行相同操作时,事情不起作用。
这是我的代码:
home.ts
firebase.firestore().collection("cities").where("timestamp", ">", "3/24/2020")
.onSnapshot(function(querySnapshot) {
var cities = [];
querySnapshot.forEach(function(doc) {
cities.push(doc.data().name);
});
console.log("Timestamp greather than 3/24/2020 -- ", cities.join(", "));
});
Run Code Online (Sandbox Code Playgroud)
一切正常,firebase.firestore().collection("cities").where("state", "==", "CA")但不适用于date.
消防栓截图:
注意:JLDdoc 应该在控制台返回,因为它的timestamp值大于3/24/2020
在@alex 的指导下,我现在正在这样做
let start = new Date('2020-03-25');
firebase.firestore().collection("cities").where("timestamp", ">", start)
但它包括2020-03-25我使用时的数据>,为什么?
我正在尝试获取设备的时间。我使用的代码是这样的 -
const estimatedDeviceTimeMs = new Date().getTime();
alert(new Date(estimatedDeviceTimeMs));
Run Code Online (Sandbox Code Playgroud)
上面代码的结果是Thu Jul 30 2020 12:01:54 GMT+0530 (India Standard Time)。
如果可能,我需要取出12:01:54一个变量和GMT+0530另一个变量。
javascript ×6
angular ×3
typescript ×3
ionic2 ×2
datetime ×1
firebase ×1
html ×1
ionic3 ×1
jquery ×1
php ×1