6
Angular.js指令动态模板URL
我在routeProvider模板中有一个需要模板的自定义标签directive。该version属性将由范围填充,然后需要正确的模板。 <hymn ver="before-{{ week }}-{{ day }}"></hymn> 根据赞美诗的星期和日期,它有多种版本。我期望使用该指令来填充正确的.html部分。不会读取变量templateUrl。 emanuel.directive('hymn', function() { var contentUrl; return { restrict: 'E', link: function(scope, element, attrs) { // concatenating the directory to the ver attr to select the correct excerpt for the day contentUrl = 'content/excerpts/hymn-' + attrs.ver + '.html'; }, // passing in contentUrl …