小编Tes*_*rag的帖子

来自 Angular Material 的 MatDialog 对话框没有关闭

我正在使用 Angular 材质对话框的 Angular 6 应用程序

  • 我试图在我的数据成功发送到服务器后成功关闭对话框,

我用过 this.dialogRef.close(0); 或 this.dialogRef.close(0); 或 this.dialogRef.close(); 但它仍然不起作用

我把我的代码放在下面

组件1.ts

let NewRegDialog = this.dialog.open(NewRegistrationComponent, {

  width: '750px',
  height: '500px',
  //disableClose: true,
  data: {
    email : email,
    regType : regType,
  },
});

NewRegDialog.afterClosed().subscribe(result => {

  if(result == 1){
    this.dialogRef.close('signup');
  }else{
    alert('Login failed') ;
    });
Run Code Online (Sandbox Code Playgroud)

组件2.ts

    import { Component, OnInit , Inject } from '@angular/core';
    import {  MatDialog  , MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';


   ... .. 
   .. .. 

      constructor( private restapi: ServicesService , private dialog: MatDialog …
Run Code Online (Sandbox Code Playgroud)

angular-material angular

15
推荐指数
3
解决办法
2万
查看次数

在父组件中的值更改时更新子组件中的值

我在 Angular 工作,在那里 -

  • 我正在尝试根据父组件中的值更改更新子组件中的值

    (因为值是从其他组件动态传到父组件的)

我是如何尝试的

  • 我尝试使用 @Input 装饰器将数据从父组件传递到子组件

  • 使用 @Input 值仅在组件加载时传递一次,而后者不传递值

我在下面分享我的代码

父组件

.html

<app-banner [tournamentType]='tournamentType'></app-banner>
Run Code Online (Sandbox Code Playgroud)

.ts

子组件

.ts 文件

import { Component, OnInit , Input } from '@angular/core';
import { ServicesService } from '../service/services.service';

@Component({
  selector: 'app-banner',
  templateUrl: './banner.component.html',
  styleUrls: ['./banner.component.scss']
})
export class BannerComponent implements OnInit {

  @Input() tournamentType;

  sportsType : any = 1;



  constructor(private rest : ServicesService) { }

  ngOnInit() {
    console.log("this. is banner page" + this.tournamentType);
    alert('hello');

    this.loadDataFromApi(1);
  }

  loadDataFromApi(sportsType) {

     this.rest.getbanner(this.sportsType).then(res => …
Run Code Online (Sandbox Code Playgroud)

angular angular5 angular6

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

以反应形式验证电子邮件和电话号码时面临的问题

我正在开发 Angular 应用程序,但在验证电子邮件和电话号码时遇到问题

问题

  1. 对于电子邮件验证问题,当我在错误的电子邮件中输入 @ 并且没有输入 .com 或 .in 示例时 -:abcd@gm .. 它不显示错误消息,

  2. 对于电话号码验证,仅当电话号码留空时才会显示错误消息,当我们输入电话号码并且超过最大长度或最小长度时,它不会显示任何错误消息。

组件.ts

import { Component, OnInit } from '@angular/core';
import { ServicesService } from '../service/services.service';
import { FormGroup  , FormControl  , Validators } from '@angular/forms';
@Component({
  selector: 'app-register',
  templateUrl: './register.component.html',
  styleUrls: ['./register.component.scss']
})
export class RegisterComponent implements OnInit {

 constructor( public restapi:ServicesService) {

    this.user = new FormGroup({

      email: new FormControl('', [Validators.required,Validators.email]),
      phone: new FormControl('', [Validators.required, Validators.minLength(10)]),
      password: new FormControl('', [Validators.required, Validators.minLength(6)])
      });

   }
ngOnInit() …
Run Code Online (Sandbox Code Playgroud)

angular angular-reactive-forms angular-forms

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

在将 gmail 与 ionic 3 集成时遇到问题,出现运行时错误 &gt;&gt;Object(...) is not a function

我正在使用ionic 3 ,我试图通过firebasegoogle plus 登录集成到我的应用程序中。但我收到错误,

错误是>>

 ERROR TypeError: Object(...) is not a function
    at GooglePlus.login (index.js:27)
    at HomePage.webpackJsonp.186.HomePage.login (home.ts:28)
    at Object.eval [as handleEvent] (HomePage.html:3)
    at handleEvent (core.js:13589)
    at callWithDebugContext (core.js:15098)
    at Object.debugHandleEvent [as handleEvent] (core.js:14685)
    at dispatchEvent (core.js:10004)
    at core.js:10629
    at HTMLButtonElement.<anonymous> (platform-browser.js:2628)
    at t.invokeTask (polyfills.js:3)


I am putting code below which I have used for integrationg google plus  Integration 
Run Code Online (Sandbox Code Playgroud)

.ts 文件

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from …
Run Code Online (Sandbox Code Playgroud)

ionic-framework ionic2 angularfire2 ionic3 angular

3
推荐指数
1
解决办法
1076
查看次数

Angular 7 Web 应用程序中的 watsapp 共享

我正在开发一个 Angular Web 应用程序,

我试图在web.watsapp.com https://web.whatsapp.com/上分享我的内容,

我用两种方式尝试过但它不起作用

这是我的代码

第一次尝试 ->

<a href="whatsapp://send?text=Proof%20That%20European%20Festival%20Fashion%20Is%20Better%20Than%20American%20Fashion%0A%0Ahttp%3A%2F%2Fwww.buzzfeed.com%2Fazafar%2Fproof-that-european-festival-fashion-is-better-than-american%3Fbfwa">Share2</a>
Run Code Online (Sandbox Code Playgroud)

第二次尝试->

<a href="whatsapp://send" data-text="Take a look at this awesome website:" data-href="" class="wa_btn wa_btn_s" style="display:none">Share1</a>  
Run Code Online (Sandbox Code Playgroud)

javascript whatsapp angular

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