【发布时间】:2016-07-05 13:45:40
【问题描述】:
我有一个parent 指令,其中包括两个子指令first 和second。我注意到只有第一个孩子被渲染。另外,如果我在第一个之前放置了一些任意的 HTML 标记,它就会全部呈现,但如果我把它们放在之后,它们就不会显示出来。这是为什么呢?
见jsfiddle:
<!-- index.html -->
<div ng-app="myApp">
<my-parent-dir />
</div>
<!-- main.js -->
var app = angular.module("myApp", []);
app.directive("myParentDir", function() {
return {
restrict: 'E',
template: '<my-first-child /> <my-second-child />'
};
});
app.directive("myFirstChild", function() {
return {
restrict: 'E',
template: '<input type="text" placeholder="first">',
};
});
app.directive("mySecondChild", function() {
return {
restrict: 'E',
template: '<input type="text" placeholder="second">',
};
});
【问题讨论】:
标签: javascript angularjs