title: Need help adding Chart.js chart to a Modal window (I'm Using AngularJS)
body: <p>I'm new to most things web development related. I've been building a prototype website for the past couple of weeks using AngularJS. 
  Due to my flawed understanding of how angular works I was redirecting to certain webpages and so breaking the app; at the time this didn't matter as it was just a quick prototype to get some ideas down.<br>
  Now however, I want to build something more realistic, and so the app must run on the one page. 
  Instead of the redirects I was using in the original prototype I've decided to implement modals to display the data within the app. 
  All has been going well so far, I can click on an item in the list and a modal window opens and displays the correct data as related to the item that was selected, except that is, for the graphs. </p>
  
  <p>I'm not sure how I should implement the graphs in the model, or to be more accurate, how I can select the canvas element to add the graph to it.</p>
  
  <p>I'm using a templateURL for the modal, and a controller to handle the modal functionality. </p>
  
  <p>Since my knowledge of javascript is dodgy at best, I've spend most of today going over the basics of Javascript and JQuery (I've been working with Angular for a couple of weeks now). </p>
  
  <p>On my static pages I use the charts as described in the Chart.js documentation. </p>
  
  <pre><code>&lt;script&gt;
                          var data = {
                              labels: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
                              datasets: [
                                  {
                                      label: "My First dataset",
                                      fillColor: "rgba(220,220,220,0.2)",
                                      strokeColor: "rgba(220,220,220,1)",
                                      pointColor: "rgba(220,220,220,1)",
                                      pointStrokeColor: "#fff",
                                      pointHighlightFill: "#fff",
                                      pointHighlightStroke: "rgba(220,220,220,1)",
                                      data: [65, 59, 80, 81, 56, 55, 40, 80, 81, 56, 55, 40]
                                  },
                                  {
                                      label: "My Second dataset",
                                      fillColor: "rgba(151,187,205,0.2)",
                                      strokeColor: "rgba(151,187,205,1)",
                                      pointColor: "rgba(151,187,205,1)",
                                      pointStrokeColor: "#fff",
                                      pointHighlightFill: "#fff",
                                      pointHighlightStroke: "rgba(151,187,205,1)",
                                      data: [28, 48, 40, 19, 86, 27, 90, 86, 27, 90, 90, 2]
                                  }
                              ]
  
                          }
                          var ctx = document.getElementById("myChart").getContext("2d");
                          var options = {responsive: true};
                          var myNewChart = new Chart(ctx).Line(data, options); 
  &lt;/script&gt;
  </code></pre>
  
  <p>This works fine when it's added to a html page that contains the <code>&lt;canvas&gt;</code> element, but it doesn't work if I include it in the modal template. Here's my modal template (without the javascript):</p>
  
  <pre><code>&lt;div id="deviceModal"&gt;
      &lt;div class="modal-header"&gt;
          &lt;div class="divBar" &gt;
              &lt;div class="{{device.status}}"&gt;&lt;img src="{{(device.type == 'type1') ? 'img/type1white.png' : 'img/type2white.png'}}"&gt; &lt;/div&gt;
              &lt;div class="title"&gt;
                  &lt;h3&gt;{{device.id}}&lt;/h3&gt;&lt;br /&gt;
  
              &lt;/div&gt;
              &lt;div class="{{device.status}}Text"&gt;&lt;b&gt;STATUS: {{device.status}}&lt;/b&gt; - {{device.action}}&lt;/div&gt;
          &lt;/div&gt; 
          &lt;div class="divBar"&gt;
              &lt;table&gt;
                  &lt;tr&gt;&lt;td class="dataLabel"&gt;Location: &lt;/td&gt;&lt;td class="dataContent"&gt;{{device.location}}&lt;/td&gt;&lt;/tr&gt;
                  &lt;tr&gt;&lt;td class="dataLabel"&gt;Running Time: &lt;/td&gt;&lt;td class="dataContent"&gt;3 days&lt;/td&gt;&lt;/tr&gt;
                  &lt;tr&gt;&lt;td class="dataLabel"&gt;Number of Starts: &lt;/td&gt;&lt;td class="dataContent"&gt;60&lt;/td&gt;&lt;/tr&gt;
              &lt;/table&gt;
          &lt;/div&gt;
          &lt;div class="divBar deviceStatistics"&gt;
              &lt;canvas id="myChart" width="400" height="200"&gt;&lt;/canvas&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And here's the modal controller built with Angular: </p>
  
  <pre><code>app.controller('modalController', function ($scope, $modal) {
  
      $scope.open = function (device) {
          $scope.device = device;
          var modalInstance = $modal.open({
              templateUrl: 'add_modal.html',
              windowClass: 'app-modal-window',
              scope: $scope
          });
  
          console.log('modal opened');
  
          modalInstance.result.then(function () {
  
              console.log('you can check user selections here');
  
          }, function () {
  
              console.log('Modal dismissed at: ' + new Date());
  
          });
  
      };
  });
  </code></pre>
  
  <p>Is it possible for me to add the chart and data in the Modal controller? or by using a directive maybe? 
  Eventually the graphs will be displaying data that's queried from a database when the user selects an item that opens the modal window. </p>
  
  <p>I've been looking at using javascript and JQuery to add the chart and data, but they require the element to be available on the page at the time of execution and that's not the case here. I've tried adding javascript to the templateURL but that doesn't work either. 
  Also, I'd imagine I should be able to do this the Angular way, can anyone suggest how that might be possible? </p>