Javascript 如何编写Angularjs嵌套转置
我正在尝试学习角度指令/转换,以控制应用程序中一些自定义面板的创建。我在某个地方出错了,转写的内容没有出现在html中 我有以下html标记:Javascript 如何编写Angularjs嵌套转置,javascript,angularjs,Javascript,Angularjs,我正在尝试学习角度指令/转换,以控制应用程序中一些自定义面板的创建。我在某个地方出错了,转写的内容没有出现在html中 我有以下html标记: <div panel-widget> <!-- this transcluded content appears --> <div panel-header></div> <div panel-body>This content doesn't</div> &
<div panel-widget>
<!-- this transcluded content appears -->
<div panel-header></div>
<div panel-body>This content doesn't</div>
</div>
此内容不可用
在我的浏览器中,我可以看到panel widget指令之后的内容,但不能看到panel body指令中的内容。这是我的指令,到目前为止相当简单
// -----------------------------------------------------------
// PANEL WIDGET DIRECTIVE
// -----------------------------------------------------------
angular.module('myApp.panel')
.directive('panelWidget', [ function() {
return {
template: '<div class="panel panel-default"><span ng-transclude></span</div>',
restrict: 'A',
transclude: true,
};
}]);
//-----------------------------------------------------------
//PANEL WIDGET DIRECTIVE
//-----------------------------------------------------------
angular.module('myApp.panel')
.directive('panelHeader', [ function() {
return {
template: '<div class="panel-heading"><h3 class="panel-title"><em>This appears</em></h3></div>',
restrict: 'A',
scope: {
headerObj: '='
}
};
}]);
// -----------------------------------------------------------
// PANEL WIDGET DIRECTIVE
// -----------------------------------------------------------
angular.module('myApp.panel')
.directive('panelBody', [ function() {
return {
template: '<div class="panel-body"><span ng-translude></span></div>',
restrict: 'A',
transclude: true,
scope: {
panelBodyObj: '='
}
};
}]);
//-----------------------------------------------------------
//面板小部件指令
// -----------------------------------------------------------
角度模块('myApp.panel')
.directive('panelWidget',[function(){
返回{
模板:“您有一个简单的输入错误:
template: '<div class="panel-body"><span ng-translude></span></div>',
模板:“”,
将ng translude
替换为ng translude
:-)您有一个简单的打字错误:
template: '<div class="panel-body"><span ng-translude></span></div>',
模板:“”,
将ng translude
替换为ng translude
:-)您在panelBody指令中拼错了ng transclude:)您在panelBody指令中拼错了ng transclude:)我刚刚在plunker上复制了它,我可以看到奇怪的内容。我还可以在您的plunker代码上看到“This exeed”从标题中消失,但“dsds”却消失了字符串存在,但标头指令没有将transclude设置为true。我以为这样会覆盖“DSDS”字符串?我只是在plunker上复制了它,我可以看到奇怪的内容。我还可以在你的plunker代码上看到,“This executes”从标头中消失了,但“DSDS”字符串在那里,但标题指令没有将transclude设置为true。我以为那样会覆盖“dsds”字符串?谢谢Michael!该死的,我不敢相信我错过了。谢谢Michael!该死的,我不敢相信我错过了。