gpt4 book ai didi

javascript - 过滤$范围错误: Unknown provider: $scopeProvider <- $scope <- transformSensorStatusFilter

转载 作者:行者123 更新时间:2023-12-03 06:55:32 25 4
gpt4 key购买 nike

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;
}
}

});

在 chrome 中,我收到以下错误:

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

最佳答案

$scope 仅适用于 Controller 和指令的链接函数。这就是过滤器找不到它的原因。也许您的意思是 $rootScope

关于javascript - 过滤$范围错误: Unknown provider: $scopeProvider <- $scope <- transformSensorStatusFilter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19311102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com