Angular模板三元不编译

时间:2019-06-12 14:20:42

标签: angular

以下模板表达式给我以下编译错误

{{
    antiAffineRules.length > 0
        ? 'vm.affinity.rules' | translate : antiAffineRules.length
        : ""
}}
  

解析器错误:条件表达式{...}在表达式末尾需要所有3个表达式

奇怪的是,在开发模式下没有出现此错误,因此jit和aot编译器之间的行为一定是不同的。

我的版本为6.1.10

1 个答案:

答案 0 :(得分:1)

这是因为解析器被:所迷惑,()被用作将参数传递给管道以及三元运算符的第二部分的方式。

您可以添加{{ antiAffineRules.length > 0 ? ('vm.affinity.rules' | translate : antiAffineRules.length) : "" }} 来帮助解析器

library(dplyr)
library(rhandsontable)
library(shiny)

hr <- list(April = tibble(ID = c("1","2","3"), 
                     Job= c("a","b","c"),
                     `Open Positions Start Of Month`=c("1","1","1"),
                     `Open Positions End Of Month`=c("1","0","1"),
                     Applicants=c("20","30","40"),
                     `First Interviews`=c("3","2","1"),
                     `Second Interviews`=c("1","1","1"),
                     Confirmations=c("0","1","0")),
       May = tibble(ID = c("1","3","4"), 
                    Job= c("a","c","d"),
                    `Open Positions Start Of Month`=c("2","1","0"),
                    `Open Positions End Of Month`=c("0","0","1"),
                    Applicants=c("10","10","40"),
                    `First Interviews`=c("2","2","2"),
                    `Second Interviews`=c("2","2","1"),
                    Confirmations=c("2","1","0")),
       June = tibble(ID = c("4","5","6"), 
                      Job= c("d","e","f"),
                      `Open Positions Start Of Month`=c("1","1","1"),
                      `Open Positions End Of Month`=c("1","0","1"),
                      Applicants=c("10","10","50"),
                      `First Interviews`=c("4","2","5"),
                      `Second Interviews`=c("3","1","3"),
                      Confirmations=c("1","1","3")))


ui <- shinyUI(fluidPage(
  titlePanel("Recruiting KPIs"),
  selectInput("input_name", "Month:", choices = names(hr), width = '20%'),

  mainPanel(
rHandsontableOutput("hot", width = 1200)
  )
)
)

server <- shinyServer(function(input, output, session) {
  values = reactiveValues()

  data = reactive({
if (!is.null(input$hot)) {
  DF = hot_to_r(input$hot)
} else {
  if (is.null(values[["DF"]]))
    DF = as_tibble(hr[[input$input_name]])
  else
    DF = values[["DF"]]
}


values[["DF"]] = DF
DF
  })

 output$hot <- renderRHandsontable({
DF = as_tibble(hr[[input$input_name]])
if (!is.null(DF))
  rhandsontable(DF, width = 1600) %>%
  hot_col( c("ID", "Open Positions Start Of Month","Open Positions End Of Month", "Applicants", "First Interviews", "Second Interviews", "Confirmations"), valign='htCenter') %>%
  hot_col("Job", valign='htLeft' ) %>%
  hot_col( c("ID", "Job", "Applicants", "First Interviews", "Second Interviews", "Confirmations"), readOnly = TRUE)  %>%
  hot_table(highlightCol = TRUE, highlightRow = TRUE) %>% hot_cols(columnSorting = TRUE) 

  })
})

shinyApp(ui = ui, server = server)