如何使用'替换'功能来定制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
收到一只叮咚
随时随地看视频慕课网APP
相关分类