Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度根据表单中的值在用户屏幕上显示数据_Javascript_Html_Json_Angular_Typescript - Fatal编程技术网

Javascript 角度根据表单中的值在用户屏幕上显示数据

Javascript 角度根据表单中的值在用户屏幕上显示数据,javascript,html,json,angular,typescript,Javascript,Html,Json,Angular,Typescript,我必须通过应用某些条件,根据通过单选按钮接收的输入在屏幕上显示数据。当从单选按钮中选择name属性时,我还需要获取对象id的帮助。 下面是我用所有基本数组和表单创建的一个示例,并在.ts文件的注释中描述了我需要的内容。我已经尽力保持代码尽可能的干净和切中要害。请让我对同样的问题做更多的澄清。谢谢。我不知道你是否看到我所做的(我不知道Stackblitz到底是如何工作的),但是 添加 const o = this.dummyData.find(x => x.hiringTypeId

我必须通过应用某些条件,根据通过单选按钮接收的输入在屏幕上显示数据。当从单选按钮中选择name属性时,我还需要获取对象id的帮助。
下面是我用所有基本数组和表单创建的一个示例,并在.ts文件的注释中描述了我需要的内容。我已经尽力保持代码尽可能的干净和切中要害。请让我对同样的问题做更多的澄清。谢谢。

我不知道你是否看到我所做的(我不知道Stackblitz到底是如何工作的),但是

添加

    const o = this.dummyData.find(x => x.hiringTypeId == this.mergeObj.hiringTypeId && x.processName == this.mergeObj.processName);
    if (o) {
      this.mergeObj.processId = o.processId;
    }
    // NOW ProcessId is set (if found)
    console.log("mergedObject",this.mergeObj)
在第61行(并将
:any
类型添加到mergeObj),将为您提供相应的对象

if(o)
块中,您甚至可以使用
o.data[0].name检索
showName
字段


和平

我不能参与闪电战

我已经试过了

请将addFilter函数更改为

addFilter(filter: NgForm) {

    Object.assign(this.mergeObj, filter.value);
    console.log("ss");

    this.finalArray = this.dummyData.filter(a => {
      return (
        (filter.value.processName == null ||
          filter.value.processName == undefined ||
          filter.value.processName == a.processName) &&
        (filter.value.hiringTypeId == null ||
          filter.value.hiringTypeId == undefined ||
          filter.value.hiringTypeId == a.hiringTypeId)
      );
    });


    filter.reset();
    console.log("mergedObject", this.mergeObj);

    //Add code here
    //Important : right now the mergedObj is giving me the processName and hiringTypeId. I want the mergeObj to give me the processId along with the processName and hiringTypeId. {processName : "selectedValue",processId : "selectedValue", hiringTypeId : "selectedValue"}
  }
你们将把结果记录到最后一页

在html中,从第25行到

<div style="border:1px solid green">
    <!-- <span>Show Data under this or legit anywhere, I have exhausted my every last motivated cell.HELP ME in the name of Baby Yoda</span> -->
    <div *ngFor="let data of finalArray">
        <div>processName : {{data.processName}}</div>
        <div>processId : {{data.processId}}</div>
        <div>hiringTypeId : {{data.hiringTypeId}}</div>
        <div>{{data.data | json}}</div>
    </div>
</div>

processName:{{data.processName}
processId:{{data.processId}
hiringTypeId:{{data.hiringTypeId}
{{data.data | json}
注意:这里我使用了filter函数,它将过滤从服务器端获取的dummayarray中的数据,但是如果您只想获取一个对象,那么可以使用find方法,它将只返回一个obj

如果你还需要什么,请告诉我


谢谢

谢谢,伙计,我试试看。仅供参考,您可以使用fork选项fork stackblitz,对其进行更改,然后共享url。显示类型{}上不存在雇用类型id的错误。你可以参与stackblitz并分享它。感谢您想要
processId
以下哪个数组
arrayOfObjects
moduleArray
dummyData
?此外,您的问题不应该只包含指向外部源(如stackblitz)的链接,而不包含问题中某些代码的任何细节。(例如,如果链接在将来变得过时,该问题将完全解决)