0

Just trying to change the background color based on the what the user clicks

HTML:

<body ng-app="myApp" ng-controller="myCtrl" style="width:100%;height:100%;background-color:{{bc}};overflow-x:hidden;padding:0px;border:0px;margin:0;">

AND

<div style="width:100%;height:20%;border:2px solid black;" ng-click="sports(FFE648);">
    <img src="logo-01.svg" style="border:2px solid black;min-width:60px;min-height:60px;width:100%;height:55%;"/>
</div>

Controller:

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $timeout) {

    $scope.sports=function(colorpick){
        $scope.animation="animated4 bounceOutRightCustom";
        $scope.animationleft="animated4 bounceOutLeftCustom";
        $scope.bc=colorpick;
        $timeout(function() {
          $scope.animation="";
          $scope.animationleft="";
            }, 4100);
    }

});
</script>

I don't know what is wrong...should be pretty simple solution :(

1
  • 2
    ng-click="sports('#FFE648');"> Commented Jul 2, 2016 at 23:48

1 Answer 1

2

Your ng-click expression is invalid. You need color to be a string.

ng-click="sports('#FFE648');">

Also I recommend you to take a look at ng-style directive.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.