Dmitry Dmitry - 4 months ago 37
CSS Question

Change font color by value

As depending on the value on the page to change the color of the text?

<div [ng-Style]="color":colorFont({{}})> {{}} {{vm.symbal}}</div><br>

Where {{}} is data (numerical value) of which should depend on the color of text. Where "ntvg" is data (string values) which should depend on the color of the text.
If greater than 0 -Red font color. Else:blue.


$scope.colorFont=function(var templiche){
if (parseFloat(templiche)>0) return color="red";
else {
return color="blue";


It seems like you are mixing Angular 1 & Angular 2 whole together by using [](property binding with directive).

As you are using A1 ng-style directive should be without placed [] square brackets & you shouldn't be using interpolation inside ng-style expression.

ng-style="{'color': colorFont(}"

Additionally function would look like below

     if (templiche>0) return 'red';
      else {
        return 'blue';

Forked Plunkr