Changing Element Colour on Hover AngularJS

后端 未结 6 758
失恋的感觉
失恋的感觉 2021-02-07 12:50

So, I\'m just getting started with angularjs and I\'m already confused. I want to change the colour of a list element that corresponds to a hex code colour that is in an array.

6条回答
  •  有刺的猬
    2021-02-07 13:28

    In Angular, there is not ng-hover directive, so you should use ng-mouseenter & ng-mouseleave to simulate it.

    
    

    And you should use $index to get your element in persons Array

    $scope.changeColor = function() {
        $scope.personColour = { 'color': '#' + $scope.persons[$index].color };
                               // or 'background-color' whatever you what
    }
    
    $scope.recoverColor = function() {
        $scope.personColour = {};
    }
    

提交回复
热议问题