我有我的看法,這些行:AngularJs:自定義指令的動態模板不是替代屬性值
<html lang="en" ng-app="localjhourlad">
.....
<ng-carousel-item
title="AngularJS custom directive's title attribute"
content="I am a custom attribute, as well!"
thumbnail="/img/logo.png">
</ng-carousel-item>
而且我app.js文件:
var ngApp = angular.module("localjhourlad", ['ngRoute']);
ngApp
.config(['$interpolateProvider',
function ($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
}]);
//Custom Directives
ngApp
.directive('ngCarouselItem', function() {
return {
restrict: 'E',
replace: true,
template: '<div class="item">' +
'<div style="background-image: url([[thumbnail]])">' +
'<div class="carousel-caption">' +
'<h3>[[title]]</h3>' +
'<p class="hidden-sm hidden-xs">[[content]]</p>' +
'</div>' +
'</div>' +
'</div>'
}
});
一切正常,因爲我看到自定義指令元素被指令的模板替換,只有表達式bindi ngs並沒有被屬性值所取代,因爲:
<div class="item"
title="AngularJS custom directive's title attribute"
content="I am a custom attribute, as well!"
thumbnail="/img/logo.png">
<div style="background-image: url()">
<div class="carousel-caption">
<h3 class="ng-binding"></h3>
<p class="hidden-sm hidden-xs ng-binding"></p>
</div>
</div>
</div>
我現在沒有想法。任何幫助將非常感激。
它是否與標準括號{{thumbnail}}一起使用? – Yashvit
本機「{{}}」和自定義「[[]]」都不起作用。完全相同的空白結果。 :( –