javascript - Directive that include page where TemplateUrl is created from an attribute -
i have meta application written in angular.js , can create apps using angular limitations. can use , create directives , create page automaticaly added $route.
i need directive widget
use other page template page url need dynamic (based on attribute) <widget name="page"/>
include template using name
attribute, here code:
return { restrict: 'ea', replace: true, transclude: true, compile: function(telement, tattrs, transclude) { this.templateurl = $route.routes['/<app-name>/' + tattrs.name].templateurl; } };
i thinking maybe can use $http fetch template, can return promise compile function , how replace template?
templateurl
can function. can write like
function geturl(telement, tattrs) { return tattrs.name; } return { restrict: 'ea', replace: true, templateurl: geturl };
angular gets template itself.
Comments
Post a Comment