Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular 2 inline style borderColor not working

Tags:

html

css

angular

I'm trying to change the border color , but it is not work.

There is my code:

<div [style.backgroundColor]="item.color"   [style.borderColor]="item.borderColor">

And in the css

display: inline-block;
  margin: 2px;
    border:2px solid ;//red;  
    height:25px;
    width:25px;
      border-radius:50%;
    -moz-border-radius:50%;
    -webkit-border-radius:50%;

The backgroundColor work , but the border not. I'm trying also :

[ngStyle]="{border: '2px solid(' + item.borderColor + ')'}"

But no effect.

like image 358
yantrab Avatar asked Dec 11 '16 17:12

yantrab


3 Answers

Try this simple solution for border to work :

[ngStyle]="{'border': '2px solid' + item.borderColor}"

This worked for me.

like image 127
Betim Shala Avatar answered Nov 02 '22 15:11

Betim Shala


You can use this

[style.border]="'2px solid ' + item.borderColor"

Hope, It will help to you.

like image 5
Raj Tukadiya Avatar answered Nov 02 '22 14:11

Raj Tukadiya


Here is some solution to make border-color dynamically changed -> In your ts file wrote this:

  get myStyles(): any {
    let color = 'red';
      return {
          'border':'1px',
          'border-style': 'solid',
          'border-color':this.dtService.border_color
      };
  }

Then in your html file -> ngStyle="myStyles"

This will make your border color change dynamically. I hope this will help you in some way. Thanks

like image 3
Atanas Iliev Avatar answered Nov 02 '22 14:11

Atanas Iliev