Jquery 自定义逻辑内部指令
如果你打开我的链接,你会看到我有两个绿色和红色的条 我想要的是用绿色条填充绿色条和红色条之间的所有间隙。在设置绿色和红色时使用指令,或者更高版本使用jquery 我的想法是,一旦我将插入绿色条,我将把变量say matchActive设置为true,随着循环的继续,直到我插入红色条,我将继续插入绿色条,但我的scope.matchActive变量被重置 指令Jquery 自定义逻辑内部指令,jquery,angularjs,Jquery,Angularjs,如果你打开我的链接,你会看到我有两个绿色和红色的条 我想要的是用绿色条填充绿色条和红色条之间的所有间隙。在设置绿色和红色时使用指令,或者更高版本使用jquery 我的想法是,一旦我将插入绿色条,我将把变量say matchActive设置为true,随着循环的继续,直到我插入红色条,我将继续插入绿色条,但我的scope.matchActive变量被重置 指令 app.directive('classset',函数($window,$timeout){ 返回{ 限制:“AEC”, 替换:fals
app.directive('classset',函数($window,$timeout){
返回{
限制:“AEC”,
替换:false,
范围:{
classSetInputValueProgram:“@”,
classSetInputValueDate:“@”,
ClassSetOutputValue:“@”,
matchActive:“=”//绑定策略
},
模板:“|”,
链接:函数(范围、elm、属性、ctrl){
$timeout(函数(){
var programdata=JSON.parse(scope.classSetInputValueProgram);
因为(让我=j;我)你的枪对我不起作用,它在起作用,让我来check@Sravan现在请检查我不理解你的问题。好的,在绿色和红色条之间做一件事,用jquery填充所有条,就像我分别用activebarstarts和activebarends类添加绿色条和红色条一样
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)
}
}
});