小编Ada*_*ery的帖子

在 Angular 中 unescape html 实体的正确方法是什么?

我从 json 文件中获取 html 实体,例如:’ 如何在 html 组件中取消转义它?

我创建了自定义管道,但它仅适用于以下实体&

import { Pipe, PipeTransform } from '@angular/core';
import {unescape} from 'lodash';

@Pipe({
  name: 'unescape'
})
export class UnescapePipe implements PipeTransform {

  transform(value: any, args?: any): any {
    return unescape(value);
  }

}
Run Code Online (Sandbox Code Playgroud)

  • 我正在使用 Angular 5。

escaping angular

8
推荐指数
2
解决办法
5806
查看次数

Angular4 Observable to Array

我需要从Observable对象中获取一些数据以便在SEO中使用(更改元标题&& description).

我通过HTTP从API获取数据.数据在Observable对象中获得.

我通过订阅this.radio $以某种方式成功转换Observable对象,但这会导致函数getRadioData(slug:string)的双重请求.

可能我需要将Observable对象转换为Array.

radio-details.component.ts(这里我想获得SEO的meta_title && meta_description变量)

import { Component, OnInit } from '@angular/core';
import { RadioDetails, RadioService } from './../services/radio.service';
import { Router, ActivatedRoute, ParamMap } from '@angular/router';
import { Observable } from 'rxjs/Observable';


@Component({
  selector: 'app-radio-details',
  templateUrl: './radio-details.component.html',
  styleUrls: ['./radio-details.component.css'],
  providers: [RadioService]    
})

export class RadioDetailsComponent implements OnInit {
  radio$: Observable<RadioDetails[]>;
  
  constructor(
    private route: ActivatedRoute,
    private router: Router,
    private service: RadioService    
  ) { }

  ngOnInit() {

this.route.paramMap
.switchMap((params: ParamMap) =>
  this.service.getRadioData(params.get('slug'))
)
.subscribe(
  (data)  => …
Run Code Online (Sandbox Code Playgroud)

observable angular

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

Angular中的错误:模板解析错误:无法绑定到'datetime',因为它不是'time'的已知属性

我想在Angular中datetimetime元素添加属性:

<time 
class="updated" 
[datetime]="post.modified_gmt">
{{ post.modified_gmt | date: 'short'}}
</time>
Run Code Online (Sandbox Code Playgroud)

但得到下一个错误:

错误:模板解析错误:无法绑定到'datetime',因为它不是'time'的已知属性.("class ="entry-date published"> {{post.date_gmt | date:'short'}}

解决方案是什么?谢谢你的帮助

time datetime angular

5
推荐指数
3
解决办法
2518
查看次数

标签 统计

angular ×3

datetime ×1

escaping ×1

observable ×1

time ×1