0

I've seem many questions like this in the site, but not of them worked for me.

I have this in app.js

   (function(){
           var app = angular.module("freelingApp", ["ngRoute"]);
           app.controller("MainController",
                   ["$http", "$scope",
                   function($http, $scope){
                          ...some code here...
                  }]);
          app.directive("dataTable", function(){
                                     return{
                                             transclude:true,
                                             replace:true,
                                             restrict: 'E',
                                             templateUrl:'data-table.html'
                                     };
                                   });

})();

Both app.js and data-table.html are at the same level in the directory

My index.html is like this:

<html>
  <head>
   ... some code here ...
  </head>

   <body ng-app="freelingApp" ng-controller="MainController">
       ... some code here...
       <div>
          <data-table></data-table>
       </div>
   </body>
</html>

And the contents of my data-table.html (for the time being because I'm testing) are:

<h1>Hello world!</h1>

Can someone tell me how to fix this ?

Crixx93
  • 727
  • 10
  • 22
  • Can you provide the proper location of your `data-table.html` relative to your `index.html` and the full URL you are using locally in your browser? – Shashank Agrawal May 22 '16 at 14:19

2 Answers2

1

If you use templateUrl, it should be relative to the web root url; Please refer this: Angular directive templateUrl relative to .js file

Community
  • 1
  • 1
Mekal
  • 340
  • 1
  • 10
0

Apparently the problem was with the the other framework I was using, Django, so changing the templates relative URL to an absolute URL fixed the issue

Crixx93
  • 727
  • 10
  • 22