使用Angular传递异步选项值

时间:2017-11-16 15:29:03

标签: angular

这是观点:

library(shiny)

suppressMessages(library("wordcloud"))

shinyUI(fluidPage(
  titlePanel("File plotter"),
  tabsetPanel(
    tabPanel("Upload File",
             titlePanel("Upload your file"),
             sidebarLayout(
               sidebarPanel(
                 fileInput('file1', 'Select your file',
                           accept='.txt'
                           ),

                 tags$br()

               ),
               mainPanel(
                 tableOutput('contents'),
                 plotOutput('messageCount')
               )
             )
    ),

    # tabPanel 1 
    tabPanel("Post Count",
             pageWithSidebar(
               headerPanel('Number of posts per user'),
               sidebarPanel(

                 # "Empty inputs" - they will be updated after the data is uploaded
                 selectInput('sender', 'Sender', "")
               ),
               mainPanel(
                 plotOutput('postCount')
               )
             )
    ),

    # tabPanel 2 
    tabPanel("Word Frequency",
             pageWithSidebar(
               headerPanel('Most commonly used words'),
               sidebarPanel(

                 # "Empty inputs" - they will be updated after the data is uploaded
                 selectInput('word', 'Sender', "")
               ),
               mainPanel(
                 plotOutput('wordCount')
               )
             )
    ),

    # tabPanel 3
    tabPanel("Chat Cloud",
             pageWithSidebar(
               headerPanel('Most used words'),
               sidebarPanel(

                 # "Empty inputs" - they will be updated after the data is uploaded
                 selectInput('cloud', 'Sender', "")
               ),
               mainPanel(
                 plotOutput('chatCloud')
               )
             )
    )



  )
)
)

当调用方法时,值记录未定义,即使它在渲染选项中正确显示。

1 个答案:

答案 0 :(得分:2)

使用[ngModel]和ngModelChange

<select name="day" [ngModel]="selectedDelovery" (ngModelChange)="showHourRange($event)">
  <option *ngFor="let delivery of deliveries$ | async"
          [value]="delivery.day">{{delivery.day | date:'dd/MM/yy'}}
  </option>
</select>