不确定,如何更多地描述这个问题。所以有简单的代码和jsfiddle
html
<div>
<span format="the value is: {{value||'no-val'}}" value="100" my-test></span>
</div>
和 javascript
App.directive('myTest', function() {
return {
restrict: 'A',
replace: true,
scope: {
format: '@'
},
template: "<span>{{format}}</span>",
link: function($scope, element, attrs) {
$scope.value = attrs.value
}
}
})
我的期望<span>the value is: 100</span>
现实<span>the value is: no-val</span>
感谢您的解释!