R shiny AngularJS working

前端 未结 1 843
眼角桃花
眼角桃花 2021-02-01 11:30

I\'m creating a dashboard with R and D3 running with library(shiny).

This works wonderfully well and now i want turn the D3 code into modular objects which will save me

相关标签:
1条回答
  • 2021-02-01 11:49

    OK this works:

    ui.r

    library(shiny)
    shinyUI(bootstrapPage(includeHTML("static.html")))
    

    server.r

    library(shiny)
    shinyServer(function(input, output) {})
    

    static.html

    <!DOCTYPE HTML>
    <html>
      <head>
        <script src="http://d3js.org/d3.v3.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>  
      </head>  
      <body>
        <script language='JavaScript'>
    
          if(typeof angular == "undefined") {
            console.log("angular == undefined");
          } else {
            console.log("angular == defined");
            console.log(angular.version.full)
          }
    
          if (window.jQuery) {  
            console.log("jQuery == defined");
            console.log(jQuery.fn.jquery);
          } else {
            console.log("jQuery == undefined");
          }
    
          d3.select("body").attr("ng-app","")
        </script>
    
          <p>Input something in the input box:</p>
          <p>Name: <input type="text" ng-model="name"></p>
          <p ng-bind="name"></p>
          <h4>Name: <input type="text" ng-model="name2"></h4>
          <h4>You wrote: {{name2}}</h4>
    
      </body>
    </html>
    

    Et voila, Up and Running ! :^)

    0 讨论(0)
提交回复
热议问题