我正在尝试使用基于Radio按钮输入的条件面板,如下所示
radioButtons("Type","Review Type:",c("Type1","Type2","Type3"),inline=T)
条件面板语句如下,
conditionalPanel(condition = "input.Type == 'Type1'",wellPanel(
radioButtons("Question1", "do you know R shiny?"choices = c("Y","N","NA"),selected = "Y",inline=T)
conditionalPanel(condition = "input.Type == 'Type2'",wellPanel(
radioButtons("Question1", "do you know Python?"choices = c("Y","N","NA"),selected = "Y",inline=T)
conditionalPanel(condition = "input.Type == 'Type3'",wellPanel(
radioButtons("Question1", "do you know Java?"choices = c("Y","N","NA"),selected = "Y",inline=T)
如果您在条件面板中注意到radioButton id(" Question1")在所有条件面板中都是相同的,条件本身对我有效,但我为所有人设置了selected = "Y"
由于某种原因无法正常工作的无线电按钮(仅适用于第三个条件面板)
答案 0 :(得分:0)
它的行为方式是因为您的所有radioButtons
都具有相同的ui <- fluidPage(
radioButtons(inputId = "Type",
label = "Review Type:",
choices = c("Type1", "Type2", "Type3"),
inline = T),
conditionalPanel(condition = "input.Type == 'Type1'",
wellPanel(
radioButtons(inputId = "Question1",
label = "do you know R shiny?",
choices = c("Y", "N", "NA"),
selected = "Y",
inline = T)
)
),
conditionalPanel(condition = "input.Type == 'Type2'",
wellPanel(
radioButtons(inputId = "Question1",
label = "do you know Python?",
choices = c("Y", "N", "NA"),
selected = "Y",
inline = T)
)
),
conditionalPanel(condition = "input.Type == 'Type3'",
wellPanel(
radioButtons(inputId = "Question1",
label = "do you know Java?",
choices = c("Y", "N", "NA"),
selected = "Y",
inline = T)
)
)
)
,因此它们只被视为一个UI元素。为您的content
提供一个唯一名称,这样可以正常使用:
angular.module('plunker', [])
.controller('MainCtrl', function ($scope) {
})
.directive('myDom', function () {
return {
restrict: 'EA',
replace: true,
transclude: true,
scope: true,
template: '<div>{{myContent}}: {{oldContent}}</div>',
controller: function () {
},
link: {
pre: function (scope, elem, attr, ctrl, transclude) {
transclude(function (clone) {
scope.myContent = attr["attri"];
scope.oldContent = clone.text();
});
}
}
};
});