R
R
Rishat Sultanov2017-08-08 08:58:02
JavaScript
Rishat Sultanov, 2017-08-08 08:58:02

How does Angular work with a table?

Good afternoon.
I have the following field:

<td 
          data-ng-class="{'danger':getStatusCell(data, 'status_start_time')}" 
          data-ng-bind="getCell(data, 'start_time')"
        ></td>

Where the fields become danger if the user is late for work. I'm not quite versed in Angular, and therefore I do not understand. How verification works. Because the field is not always danger, and I cannot find a check.
The methods that are used.
$scope.getStatusCell = function(data, name) {
    return data[name] == 0;
  }

  $scope.getCell = function(data, name) {


    if(!!~name.indexOf('range')){
      return (data[name]>1000)?(data[name]/1000)+"km":data[name]+"m";
    }else{
      if(!data["f_"+name]) {
        return "-";
      }
      return data[name]+"/"+data["f_"+name]+" ("+data["diff_"+name]+")";
    }
  }

data example
{city_id: 11, city: "Pavlodar", shop_id: 32, shop: "Павлодар 3, пр. Кутузова 44", user: "Тест дата", …}
$$hashKey
:
"020"
city
:
"Pavlodar"
city_id
:
11
created_at
:
"2017-08-08 11:47:29"
diff_end_time
:
0
diff_lunch_end_time
:
0
diff_lunch_start_time
:
0
diff_range_end_time
:
0
diff_range_lunch_end_time
:
0
diff_range_lunch_start_time
:
0
diff_range_start_time
:
58
diff_start_time
:
-12
end_time
:
""
f_end_time
:
""
f_lunch_end_time
:
""
f_lunch_start_time
:
""
f_start_time
:
"11:47"
fake
:
0
imei
:
"3574060723352846"
lunch_end_time
:
""
lunch_start_time
:
""
range
:
"100"
shop
:
"Павлодар 3, пр. Кутузова 44"
shop_id
:
32
start_time
:
"12:00"
status_end_time
:
0
status_lunch_end_time
:
0
status_lunch_start_time
:
0
status_range_end_time
:
0
status_range_lunch_end_time
:
0
status_range_lunch_start_time
:
0
status_range_start_time
:
1
status_start_time
:
1
user
:
"Тулеген Батыр"
ymd
:
"2017-08-08 00:00:00"
__proto__
:
Object

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2017-08-08
@rishatss

data-ng-class="{'danger':getStatusCell(data, 'status_start_time')}"

depending on the result of calling the getStatusCell function (true/false), the class is assigned or not

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question