通过背景颜色区分不同的结果

时间:2016-08-04 07:01:53

标签: javascript html node.js strongloop apic

我想用不同的颜色区分这些值。这是我想做什么的粗略概念。我能够为按钮而不是在桌子上做。当从数据库中检索值时,我想根据diary.level值放置背景颜色。 sample of my intended end result

Health.js

var app = (function () {
 
        var privateVar = 'hello world';
 
        function sayhelloPrivate() {
             console.log(privateVar);
        }
 
        function sayhelloPublic() {
            console.log(privateVar);
        }
 
        // reveal public pointers to
        // private functions and properties
 
       return {
            sayhello : sayhelloPublic 
        };

    })();
 
app.sayhello();
//app.sayhelloPrivate(); this will not work as function is private and not visible outside module

data.html

    angular
  .module('app')
  .controller('TrackingController', ['$scope', 'Diary', '$state', function($scope, Diary, $state) {
    $scope.diaries = [];

    $scope.submitForm = function() {
      Diary
        .upsert({
          date: $scope.diary.date,
          taken: $scope.diary.taken,
          level: $scope.diary.level
        })
        .$promise
        .then(function() {
          $state.go('data');
        });
    };
  }])

    .controller('DataController', ['$scope', 'Diary', function ($scope, Diary) {
        $scope.diaries = Diary.find();

            if($scope.diary.level == "1-3.8") {
            $scope.buttonClass = "background-color:lightgreen";
            }
            else if ($scope.diary.level == "4-7") {
                $scope.buttonClass = "background-color:tomato";
            }
            else if ($scope.diary.level == "7.2-10.0") {
                $scope.buttonClass = "background-color:purple";
            }
            else {
                $scope.buttonClass = "background-color:yellow";
            }
    }]) 

1 个答案:

答案 0 :(得分:0)

编写一个辅助函数,可以为日记列表中的每个项调用。

sed -i "s/keywords_extraction/group_knapsack/g" `grep keywords_extraction -rl ./`