samedi 27 juin 2015

Change background color from input

I'm using angular. I have a input that looks like:

<input class="form-control" type="text" ng-model="newBook.color">

basically when this is changed, I want a div's background color to be changed.

My controller has some lines that look like:

$scope.newBook = {};
$scope.newBook.color = "";

$scope.color = ->
  return "background-color: " + $scope.newBook.color;

and then the div I want to change:

<div ng-style="{{color()}}"></div>

However, I get the error: Error: [$parse:syntax] Syntax Error: Token ':' is an unexpected token at column 17 of the expression [background-color:]

Aucun commentaire:

Enregistrer un commentaire