我正在尝试添加一些过滤器以根据某些触发器显示相关问题。
这里是小提琴网址
var app = angular.module('myapp', [])
.directive("textquestion", function(){
return {
restrict: 'A',
template : '<label>{{question.displayText}}<br/><input name="{{question.qstnNo}}" type="text"/></label>',
scope : { question: '=textquestion' }
};
})
.directive("radioquestion", function(){
return {
restrict: 'A',
template : '{{question.displayText}}<br/><label ng-repeat="resp in question.demographicResponses"><input name="{{question.qstnNo}}" type="radio" value="{{resp.respNo}}" /> {{resp.possibleResponse}} </label> ',
scope : { question: '=radioquestion' }
};
})
.directive("multiquestion", function(){
return {
restrict: 'A',
template : '{{question.displayText}}<br/><label ng-repeat="resp in question.demographicResponses"><input name="{{question.qstnNo}}" type="checkbox" value="{{resp.respNo}}" /> {{resp.possibleResponse}} </label>',
scope : { question: '=multiquestion' }
};
})
.directive("selectquestion", function(){
return {
restrict: 'A',
template : '{{question.displayText}}<br/><label> <select name="{{question.qstnNo}}"><option ng-repeat="resp in question.demographicResponses" value="{{resp.respNo}}"> {{resp.possibleResponse}}</option></select></label>',
scope : { question: '=selectquestion' }
};
})
.controller('ctrl', function($scope){
$scope.questions = [
{
"seqNo":0,
"qstnNo":34,
"responseType":"F",
"responseRequired":false,
"displayText":"If you have been provided with a state ID enter it here",
"demographicResponses":[
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":2,
"qstnNo":2,
"responseType":"R",
"responseRequired":true,
"displayText":"What is your ethnicity?",
"demographicResponses":[
{
"possibleResponse":"Non-Hispanic",
"seqNo":2,
"respNo":201
},
{
"possibleResponse":"Hispanic",
"seqNo":2,
"respNo":202
},
{
"possibleResponse":"I prefer not to respond",
"seqNo":2,
"respNo":203
}
],
"dependentQuestionVO":[
{
"dependentQstnNo":3,
"triggerRespNo":202,
"triggerArrayElement":"[202,3]"
}
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":3,
"qstnNo":3,
"responseType":"R",
"responseRequired":true,
"displayText":"What is your Hispanic origin?",
"demographicResponses":[
{
"possibleResponse":"Mexican, Mexican, or Chicano",
"seqNo":3,
"respNo":301
},
{
"possibleResponse":"Puerto Rican or Puerto Rican American",
"seqNo":3,
"respNo":302
},
{
"possibleResponse":"Cuban or Cuban American",
"seqNo":3,
"respNo":303
},
{
"possibleResponse":"Other",
"seqNo":3,
"respNo":304
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":true,
"answered":false,
"triggered":false
},
{
"seqNo":4,
"qstnNo":4,
"responseType":"M",
"responseRequired":true,
"displayText":"What is your race? Select all that apply.",
"demographicResponses":[
{
"possibleResponse":"American Indian or Alaskan Native",
"seqNo":4,
"respNo":401
},
{
"possibleResponse":"Asian",
"seqNo":4,
"respNo":402
},
{
"possibleResponse":"Black or African American",
"seqNo":4,
"respNo":403
},
{
"possibleResponse":"Native Hawaiian or Other Pacific Islander",
"seqNo":4,
"respNo":404
},
{
"possibleResponse":"White",
"seqNo":4,
"respNo":405
},
{
"possibleResponse":"Other",
"seqNo":4,
"respNo":406
},
{
"possibleResponse":"I prefer not to respond",
"seqNo":4,
"respNo":407
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":5,
"qstnNo":5,
"responseType":"R",
"responseRequired":true,
"displayText":"Do you communicate better (or as well) in English than in any other language?",
"demographicResponses":[
{
"possibleResponse":"Yes",
"seqNo":5,
"respNo":501
},
{
"possibleResponse":"No",
"seqNo":5,
"respNo":502
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":6,
"qstnNo":6,
"responseType":"R",
"responseRequired":false,
"displayText":"Which of the following best describes your current employment status?",
"demographicResponses":[
{
"possibleResponse":"Employed part-time (29 or fewer hours per week)",
"seqNo":6,
"respNo":601
},
{
"possibleResponse":"Employed full-time",
"seqNo":6,
"respNo":602
},
{
"possibleResponse":"Unemployed (seeking employment)",
"seqNo":6,
"respNo":603
},
{
"possibleResponse":"Not in the labor force (homemaker, family caregiver, student, retired )",
"seqNo":6,
"respNo":604
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":7,
"qstnNo":7,
"responseType":"S",
"responseRequired":false,
"displayText":"What was the last grade of school that you completed?",
"demographicResponses":[
{
"possibleResponse":"5th grade or lower",
"seqNo":7,
"respNo":701
},
{
"possibleResponse":"6th grade",
"seqNo":7,
"respNo":702
},
{
"possibleResponse":"7th grade",
"seqNo":7,
"respNo":703
},
{
"possibleResponse":"8th grade",
"seqNo":7,
"respNo":704
},
{
"possibleResponse":"9th grade (high school freshman)",
"seqNo":7,
"respNo":705
},
{
"possibleResponse":"10th grade (high school sophomore)",
"seqNo":7,
"respNo":706
},
{
"possibleResponse":"11th grade (high school junior)",
"seqNo":7,
"respNo":707
},
{
"possibleResponse":"12th grade (high school senior)",
"seqNo":7,
"respNo":708
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":8,
"qstnNo":8,
"responseType":"F",
"responseRequired":false,
"displayText":"What was the name of last K-12 school you attended?",
"demographicResponses":[
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":9,
"qstnNo":9,
"responseType":"F",
"responseRequired":false,
"displayText":"City of last K-12 school attended",
"demographicResponses":[
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"possibleResponse":"Don't Know",
"seqNo":13,
"respNo":1308
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":14,
"qstnNo":14,
"responseType":"R",
"responseRequired":false,
"displayText":"Please indicate the highest level of education completed by your <u>father</u>.",
"demographicResponses":[
{
"possibleResponse":"Grade school or less",
"seqNo":14,
"respNo":1401
},
{
"possibleResponse":"Some high school",
"seqNo":14,
"respNo":1402
},
{
"possibleResponse":"High school",
"seqNo":14,
"respNo":1403
},
{
"possibleResponse":"Some college/university",
"seqNo":14,
"respNo":1404
},
{
"possibleResponse":"Associate degree",
"seqNo":14,
"respNo":1405
},
{
"possibleResponse":"Bachelor's degree",
"seqNo":14,
"respNo":1406
},
{
"possibleResponse":"Some graduate or professional school or a graduate or professional degree",
"seqNo":14,
"respNo":1407
},
{
"possibleResponse":"Don't Know",
"seqNo":14,
"respNo":1408
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":15,
"qstnNo":15,
"responseType":"R",
"responseRequired":false,
"displayText":"What is your primary reason for taking the HiSET? Select the <strong>one</strong> which best applies.",
"demographicResponses":[
{
"possibleResponse":"Enroll in technical or trade program",
"seqNo":15,
"respNo":1501
},
{
"possibleResponse":"Enter a 2 year college",
"seqNo":15,
"respNo":1502
},
{
"seqNo":20,
"qstnNo":20,
"responseType":"R",
"responseRequired":false,
"displayText":"With 1 being \"No difference\" and 6 being a \"Significant difference\" indicate the extent to which <strong>financial difficulties</strong> have made a difference in your life over the last 12 months.",
"demographicResponses":[
{
"possibleResponse":"1 - No difference",
"seqNo":20,
"respNo":2001
},
{
"possibleResponse":"2",
"seqNo":20,
"respNo":2002
},
{
"possibleResponse":"3",
"seqNo":20,
"respNo":2003
},
{
"possibleResponse":"4",
"seqNo":20,
"respNo":2004
},
{
"possibleResponse":"5",
"seqNo":20,
"respNo":2005
},
{
"possibleResponse":"6 - Significant difference",
"seqNo":20,
"respNo":2006
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":21,
"qstnNo":21,
"responseType":"R",
"responseRequired":false,
"displayText":"With 1 being \"No difference\" and 6 being a \"Significant difference\" indicate the extent to which <strong>legal issues</strong> have made a difference in your life over the last 12 months.",
"demographicResponses":[
{
"possibleResponse":"1 - No difference",
"seqNo":21,
"respNo":2101
},
{
"possibleResponse":"2",
"seqNo":21,
"respNo":2102
},
{
"possibleResponse":"3",
"seqNo":21,
"respNo":2103
},
{
"possibleResponse":"4",
"seqNo":21,
"respNo":2104
},
{
"possibleResponse":"5",
"seqNo":21,
"respNo":2105
},
{
"possibleResponse":"6 - Significant difference",
"seqNo":21,
"respNo":2106
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":22,
"qstnNo":22,
"responseType":"R",
"responseRequired":false,
"displayText":"With 1 being \"No difference\" and 6 being a \"Significant difference\" indicate the extent to which <strong>family obligations</strong> have made a difference in your life over the last 12 months.",
"demographicResponses":[
{
"possibleResponse":"1 - No difference",
"seqNo":22,
"respNo":2201
},
{
"possibleResponse":"2",
"seqNo":22,
"respNo":2202
},
{
"possibleResponse":"3",
"seqNo":22,
"respNo":2203
},
{
"possibleResponse":"4",
"seqNo":22,
"respNo":2204
},
{
"possibleResponse":"5",
"seqNo":22,
"respNo":2205
},
{
"possibleResponse":"6 - Significant difference",
"seqNo":22,
"respNo":2206
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":23,
"qstnNo":23,
"responseType":"R",
"responseRequired":false,
"displayText":"With 1 being \"No difference\" and 6 being a \"Significant difference\" indicate the extent to which <strong>issues with your health</strong> have made a difference in your life over the last 12 months.",
"demographicResponses":[
{
"possibleResponse":"1 - No difference",
"seqNo":23,
"respNo":2301
},
{
"possibleResponse":"2",
"seqNo":23,
"respNo":2302
},
{
"possibleResponse":"3",
"seqNo":23,
"respNo":2303
},
{
"possibleResponse":"4",
"seqNo":23,
"respNo":2304
},
{
"possibleResponse":"5",
"seqNo":23,
"respNo":2305
},
{
"possibleResponse":"6 - Significant difference",
"seqNo":23,
"respNo":2306
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":24,
"qstnNo":24,
"responseType":"S",
"responseRequired":false,
"displayText":"Thinking about yourself: to what extent do you agree with the statement \"I tend to do more than what is expected of me.\"",
"demographicResponses":[
{
"possibleResponse":"Strongly Disagree",
"seqNo":24,
"respNo":2401
},
{
"possibleResponse":"Disagree",
"seqNo":24,
"respNo":2402
},
{
"possibleResponse":"Slightly Disagree",
"seqNo":24,
"respNo":2403
},
{
"possibleResponse":"Slightly Agree",
"seqNo":24,
"respNo":2404
},
{
"possibleResponse":"Agree",
"seqNo":24,
"respNo":2405
},
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":28,
"qstnNo":28,
"responseType":"S",
"responseRequired":false,
"displayText":"Thinking about yourself: to what extent do you agree with the statement \"I tend to give up easily.\"",
"demographicResponses":[
{
"possibleResponse":"Strongly Disagree",
"seqNo":28,
"respNo":2801
},
{
"possibleResponse":"Disagree",
"seqNo":28,
"respNo":2802
},
{
"possibleResponse":"Slightly Disagree",
"seqNo":28,
"respNo":2803
},
{
"possibleResponse":"Slightly Agree",
"seqNo":28,
"respNo":2804
},
{
"possibleResponse":"Agree",
"seqNo":28,
"respNo":2805
},
{
"possibleResponse":"Strongly Agree",
"seqNo":28,
"respNo":2806
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
{
"seqNo":29,
"qstnNo":29,
"responseType":"S",
"responseRequired":false,
"displayText":"Thinking about yourself: to what extent do you agree with the statement \"I work on tasks until everything is perfect.\"",
"demographicResponses":[
{
"possibleResponse":"Strongly Disagree",
"seqNo":29,
"respNo":2901
},
{
"possibleResponse":"Disagree",
"seqNo":29,
"respNo":2902
},
{
"possibleResponse":"Slightly Disagree",
"seqNo":29,
"respNo":2903
},
{
"possibleResponse":"Slightly Agree",
"seqNo":29,
"respNo":2904
},
{
"possibleResponse":"Agree",
"seqNo":29,
"respNo":2905
},
{
"possibleResponse":"Strongly Agree",
"seqNo":29,
"respNo":2906
}
],
"dependentQuestionVO":[
],
"selectedResponseIds":null,
"freeFormAnswer":null,
"isdependent":false,
"answered":false,
"triggered":false
},
];});
现在我想要的是根据triggerRespNo显示依赖问题3是问题3:202
我需要编写一个过滤器来做到这一点。任何帮助将不胜感激。
先谢谢