user11561629
user11561629

Reputation: 71

Not able to create border dynmaically using ngstyle in angularjs

I have applied this condition on element but it is not showing any border also it is not showing any error in parsing html:

<h1 ng-style="'{border:' + f()+'px' + 'solid red'+'}'">{{a}}</h1>

Here is the code from my controller:

$scope.a = "dynamic border";
$scope.f = function() {
  return 1;
};

Upvotes: 1

Views: 52

Answers (1)

NTP
NTP

Reputation: 4448

Your code is mostly correct, only small issues with placement of '. Try the following please.

<h1 ng-style="{'border': f() + 'px solid red'}">{{a}}</h1>

Demo

Upvotes: 2

Related Questions