如何使用'替換'功能來定制AngularJS指令?為什么replace=true還是replace=false沒有在下面的代碼產生任何影響?當replace = false時,為什么不顯示“某些現有內容”?或者更謙虛地說,你能否解釋一下replace=true/false指令中的功能是什么以及如何使用它?例JS /角:<script>
angular.module('scopes', [])
.controller('Ctrl', function($scope) {
$scope.title = "hello";
})
.directive('myDir', function() {
return {
restrict: 'E',
replace: true,
template: '<div>{{title}}</div>'
};
});</script>HTML:<div ng-controller="Ctrl">
<my-dir><h3>some existing content</h3></my-dir></div>在Plunker中看到它:http://plnkr.co/edit/4ywZGwfsKHLAoGL38vvW?p=preview
- 0 回答
- 0 關注
- 643 瀏覽
添加回答
舉報
0/150
提交
取消