Если вы откроете мою ссылку, вы увидите, что у меня есть две полосы зеленого и красного цвета.
То, что я хочу, это заполнить все промежутки между зелеными и красными полосами зелеными полосами. либо с директивой, когда я устанавливаю зеленый и красный, либо позже с jquery.
https://plnkr.co/edit/OpExVrfuMf5YcbmU3D5g?p=preview
как я думаю, когда я вставлю зеленую полосу, я установлю переменную, скажем, matchActive в true, и пока цикл продолжается до тех пор, пока я вставлю красную полосу, я продолжу вставлять зеленую полосу, но моя переменная scope.matchActive будет сброшена.
Директива
app.directive('classset', function($window, $timeout) {
return {
restrict: 'AEC',
replace: false,
scope: {
classSetInputValueProgram: '@',
classSetInputValueDate: '@',
ClassSetOutputValue: '@' ,
matchActive: '=' // binding strategy
},
template: '<span class="{{ClassSetOutputValue}} rowbarWidth">|</span>',
link: function(scope, elm, attrs, ctrl) {
$timeout(function() {
var programdata = JSON.parse(scope.classSetInputValueProgram);
for(let i=j;i<=programdata.length;i++)
{
//if data exist
if(programdata[i])
{
if(programdata[i].scheduledDate == scope.classSetInputValueDate )
{ console.log('equal startd'+i)
console.log(programdata[i]);
scope.ClassSetOutputValue = 'activebarstarts';
scope.matchActive = true;
return true;
}
else if(programdata[i].programEndDate == scope.classSetInputValueDate)
{ console.log('equal'+i)
console.log(programdata[i]);
scope.ClassSetOutputValue = 'activebarends';
scope.matchActive = false;
return true;
}
else
{
//console.log('not equal'+i)
//scope.matchActive = true;
}
}
else
{
// console.log('not exist'+i);
// scope.ClassSetOutputValue = 'activebarstarts';
// return true;
//scope.matchActive = false;
// scope.ClassSetOutputValue = 'activebarstarts';
//return true;
}
}
},10)
}
}
});