Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
159
rated 0 times [  164] [ 5]  / answers: 1 / hits: 34455  / 11 Years ago, fri, october 11, 2013, 12:00:00
marsApp.filter(transformSensorStatus, function($scope) {
return function(input, options) {

var sensorReading = ( input ? ( input / 1000) : 0);
var sensorLowLimit = (options[lowLimit] ? (options[lowLimit] / 1000) : 0);
var sensorHighLimit = (options[highLimit] ? (options[highLimit] / 1000) : 0);
var curStat;
switch (sensorReading) {
case 255:
case 254:
case 253:
curStat = generateStateInnerHtml(sensorReading);
break;
default:
curStat = generateStateInnerHtml(options[sensorStatus]);

}

return curStat;


function generateStateInnerHtml(state) {

var stateHtml = null;

if (state == 255 || state == 254) {
stateHtml = a;
$scope.sensorStateColor='';
return state_html;
}
if (state == 253) {
stateHtml = b;
$scope.sensorStateColor=text-warning;
return state_html;
}
if (state >= 0x20) {
stateHtml = c;
$scope.sensorStateColor=text-error;
return stateHtml;
}
if (state >= 0x02) {
stateHtml = d;
$scope.sensorStateColor=text-error;
return stateHtml;
}
if (state == 0x01) {
stateHtml = e;
$scope.sensorStateColor=text-success;
return stateHtml;
}
stateHtml = N/A;
return stateHtml;
}
}


});



in chrome , I get the following error:




Error: Unknown provider: $scopeProvider <- $scope <-
transformSensorStatusFilter



More From » angularjs

 Answers
11

The $scope is available only for controllers and the link function of directives. This is why the filter cannot find it. Maybe you meant $rootScope?


[#75073] Thursday, October 10, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ryley

Total Points: 118
Total Questions: 81
Total Answers: 102

Location: Kazakhstan
Member since Thu, Dec 23, 2021
2 Years ago
;