您可以使用
ng-include指令。
尝试这样的事情:
emanuel.directive('hymn', function() { return { restrict: 'E', link: function(scope, element, attrs) {scope.getContentUrl = function() { return 'content/excerpts/hymn-' + attrs.ver + '.html';} }, template: '<div ng-include="getContentUrl()"></div>' }});UPD。 用于观看ver
属性
emanuel.directive('hymn', function() { return { restrict: 'E', link: function(scope, element, attrs) {scope.contentUrl = 'content/excerpts/hymn-' + attrs.ver + '.html';attrs.$observe("ver",function(v){ scope.contentUrl = 'content/excerpts/hymn-' + v + '.html';}); }, template: '<div ng-include="contentUrl"></div>' }});


