javascript - ngx-translate innerHTML styling - Stack Overflow

I using Angular 5.0.1 and ngx-translatecore 8.0.0I have this code in template<p [innerHTML]="&

I using Angular 5.0.1 and ngx-translate/core 8.0.0

I have this code in template

<p [innerHTML]="'privacyAgree'|translate:{href:'#'}"></p>

and this string in en.json

"privacyAgree": "Clicking «Registration» button, I accept<a href=\"{{href}}\">the terms</a>"

and this code in my less file

p{
    color: #8A8C8D;
    font-size: 13px;
    line-height: 1.4em;
    a{
        color: #222222;
    }
}

but color for inner "a" will not apply because Angular create this styles

p[_ngcontent-c3] {
  color: #8A8C8D;
  font-size: 13px;
  line-height: 1.4em;
}
p[_ngcontent-c3]   a[_ngcontent-c3] {
  color: #222222;
}

but ngx-translate create this code

<p _ngcontent-c3="">Clicking «Registration» button, I accept<a href="#">the terms</a></p>

and "a" tag doesn't have necessary attribute.

So how I can render [innerHTML] template after translation?

I using Angular 5.0.1 and ngx-translate/core 8.0.0

I have this code in template

<p [innerHTML]="'privacyAgree'|translate:{href:'#'}"></p>

and this string in en.json

"privacyAgree": "Clicking «Registration» button, I accept<a href=\"{{href}}\">the terms</a>"

and this code in my less file

p{
    color: #8A8C8D;
    font-size: 13px;
    line-height: 1.4em;
    a{
        color: #222222;
    }
}

but color for inner "a" will not apply because Angular create this styles

p[_ngcontent-c3] {
  color: #8A8C8D;
  font-size: 13px;
  line-height: 1.4em;
}
p[_ngcontent-c3]   a[_ngcontent-c3] {
  color: #222222;
}

but ngx-translate create this code

<p _ngcontent-c3="">Clicking «Registration» button, I accept<a href="#">the terms</a></p>

and "a" tag doesn't have necessary attribute.

So how I can render [innerHTML] template after translation?

Share Improve this question edited Nov 21, 2017 at 13:50 Ruslan asked Nov 21, 2017 at 13:13 RuslanRuslan 1082 silver badges8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

You have to change Encapsulation mode of your ponent.

Check this question, it had similar problem.

Encapsulation

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745650907a4638258.html

相关推荐

  • javascript - ngx-translate innerHTML styling - Stack Overflow

    I using Angular 5.0.1 and ngx-translatecore 8.0.0I have this code in template<p [innerHTML]="&

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信