Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Directive with templateUrl - Issue on Plunker?

Can I link to a specific file within a Plunker? Specifically, I'd like to use Angular's "templateUrl" within a directive to externalize the HTML for a directive I'm building:

myApp.directive('groupedlist', function() {
  return {
    restrict: 'E',
    scope: true,
    templateUrl: '/groupedList.html',
    link: function() {}
  };
});

I have a file called "groupedList.html" that contains a HTML template, but it seems like these are logical files within a Plunker project - my browser complains because it can't find groupedList.html. Is it possible to do what I'm trying to do using Plunker? I'd rather not use the "template" attribute because there is a not-insignificant amount of HTML content I'd like to externalize.

like image 962
blaster Avatar asked Apr 19 '13 16:04

blaster


1 Answers

templateUrl doesnt work with absolute URLs, use relative URL instead (like './page.html' or '../templates/page.html'). If u need to load cross domain page to template, u can do a request (XMLHttpRequest) and set STRING HTML as a template.

like image 131
Rafael Kazuo Sato Simiao Avatar answered Sep 28 '22 12:09

Rafael Kazuo Sato Simiao