How is it that the first function works, yet the second one doesn't?
<p ng-style="colors.one">1</p>
$scope.turnOn = function()
{
$scope.colors.one = {color: "green"};
}
$scope.turnOff = function(num)
{
$scope.colors.num = {color: "red"};
}
$scope.turnOn();
$scope.turnOff(one);
EDIT I tried adding num on $scope.colors like you guys suggested, still can't seem to figure it out.
$scope.turnOn = function(num)
{
$scope.colors[num] = {color: "green"};
}
$scope.turnOff = function(num)
{
$scope.colors[num] = {color: "red"};
}
I'm calling the functions through
<button ng-switch-when='false' ng-click='turnOn(one)'>
<button ng-switch-when='true' ng-click='turnOff(one)'>