title: AngularJS: Getting a List into custom directive is not working
body: <p>I am  creating a custom directive. Here, I am using an itemsList which is defined in the controller. This itemsList contains all the data I want to display on the page. 
  This is my custom directive</p>
  
  <pre><code>directives.directive('studenttemplate', function($compile) {
       return {
              restrict: "E",
              scope: true,
              link: function(scope, element, attrs) {
                  var htmlcontent = "";
                  var studentItem = scope.itemsList;
                  console.log("Inside the Directive", scope.items);
  
                 for (var i = 0; i &lt; studentItem; i++){
                          htmlcontent = htmlcontent
                              + "&lt;tr&gt;"                    
                      + "&lt;td&gt;"
                      + studentItem[i].name
                      + "&lt;/td&gt;"   
                      + "&lt;td&gt;"
                      + studentItem[i].mobile
                      + "&lt;/td&gt;"
                      + "&lt;td&gt;"
                      + studentItem[i].address
                      + "&lt;/td&gt;&lt;/tr&gt;"
                  }
              element.append(htmlcontent)
                  $compile(element.contents())(scope);
               }
          }
  });
  </code></pre>
  
  <p>I am getting <code>undefined</code> at <code>scope.itemsList</code>. But when I use normal HTML code it is working fine. I don't know what is causing issue.</p>
  
  <p>This is my controller code is</p>
  
  <pre><code>$scope.items = stuservice.getList(defaultUrl);
          $scope.items.then(function(data) {
              $scope.itemsList = data.list;
          });
  </code></pre>
  
  <p>Any help would appreciated. Thanks</p>