小编ilm*_*ico的帖子

以角度创建函数的困惑

我是 Angular 的新手,在 Jquery 中,当您处理一段需要再次使用的代码时,通常我们会创建一个 js 文件或函数以在需要时调用,在 Angular 中我有同样的问题,但如果我应该这样做,我会很伤心为它或js或函数创建一个组件,因为我想知道最佳实践,这是我的代码:

  public valueChange(value: string): void {
              this.from= formatDate( this.value,'yyyy-MM-dd', 'en_US');
              this.to=formatDate( this.value1,'yyyy-MM-dd', 'en_US');
              this.Legendtemp.push(value);
              this.serisName= value;
              this.services.getWindAverage(value,this.from,this.to).subscribe(s=>{
              this.selected=s;
              this.series.push(this.selected);
              i=this.series.length-1;      
              })
              this.temp.push(value.length);
              }
     else{
              console.log("Dseleted");
              if(this.temp.length!=0){this.temp.pop();this.series.pop();this.temp.length}   
             }
             }
Run Code Online (Sandbox Code Playgroud)

它的 multiselectBox 获取选定的值将它们推入一个数组并与日期一起传递到后端,现在我在此页面的其他地方添加了一个过滤器按钮,它应该做同样的事情,最好的做法是什么棱角分明?

angular

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

Angular orderBy pipe

我想按属性名称排序我的结果,但以下给了我一个错误:

*ngFor="let s of rslt| order by:wind_park">
Run Code Online (Sandbox Code Playgroud)

我从后端得到的:

data = [
  { turbine_name: "Baynne ", wind_park: "Bayone" },
  { turbine_name: "Salstiegl ", wind_park: "Salzst" },
  { turbine_name: "Chradurga - SLL2", wind_park: "Chiarga" },
  { turbine_name: "Moilishte ", wind_park: "Mogihte" },
  { turbine_name: "Mogshte ", wind_park: "Mogshte" }
]
Run Code Online (Sandbox Code Playgroud)

我如何订购它以及最佳做法是什么?谢谢大家。

angular

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

标签 统计

angular ×2