- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
抱歉,如果我在这里遗漏了一些愚蠢的东西,但我真的尝试了各种组合来使这段代码工作,但没有成功。
我正在从 Recipes with AngularJS
学习 AngularjS
中的 directive
但卡在这段代码 -
https://github.com/fdietz/recipes-with-angular-js-examples/tree/master/chapter3/recipe4
我相信它应该在Hello World p
文本之前打印Heading。但它不会来。让我知道我的代码中缺少什么 -
作为一个整体的代码 -
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8" />
<title>Directive Example</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.min.js"></script>
<script>
var myApp = angular.module("myApp", []);
myApp.directive("myWidget", function(){
return {
restrict: "E",
transclude: true,
template: "<div ng-transclude><h3>Heading</h3></div>"
};
});
</script>
</head>
<body>
<my-widget>
<p>Hello World!!</p>
</my-widget>
</body>
</html>
最佳答案
检查“div”之前的第一个“h3”
template: "<h3>Heading</h3><div ng-transclude></div>"
关于javascript - ng-transclude 在模板 AngularJS 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25725787/
我有一个 myList指令,它包含它的内容。当我尝试嵌套 时出现问题另一个元素 . JS fiddle :http://jsfiddle.net/fqj5svhn/ 指令: var MyListD
我在另一个指令中有一个 Angular Directive(指令)。两者都使用 transclude: true。 我希望如果我有以下代码(取自 plunker)我会看到同样的事情 3 次。 http
关于 Angular 1.5.8 组件内嵌入的问题及其用途。 这是一些代码的示例; var app = angular.module('app', []) function AccordionCont
我实现了一个指令,将子内容的多个片段嵌入到模板中。它有效,但似乎比我见过的大多数示例更简单,并提出了一些关于嵌入如何工作的问题。 这是指令: module.directive('myTransclud
我应该什么时候使用 transclude: 'true'当 transclude: 'element' ? 我找不到关于 transclude: 'element' 的任何信息在 angular 文档
我有一个带有嵌入文本的指令,我需要将它放在占位符中 我的html Hello world! JS (function(angular) { 'use strict'; angular
我想创建一个具有嵌入部分的组件,这是一个示例: http://jsfiddle.net/vp2dnj65/1/ 正如您所见,单击“执行”按钮时没有任何反应。 有没有办法从放置在嵌入部分内的组件运行嵌入
我在模板中有一个带有 ng-repeat 的指令,但我还想在中继器后面有一个 ng-transinclude 以允许用户插入自己的内容。问题是自定义内容在渲染时被包装在 ng-transclude 元
我有一个名为“panel”的自定义指令。 One Body two 我的问题是我无法渲染嵌套面板指令。请参阅plunkr http://plnkr.co/edit/D0LfQqBV
此示例适用于 AngularJS 1.1.5(它将把它附加到 div 中),但不适用于 1.2.5(它留下没有附加的 html 内容)。 https://egghead.io/lessons/angu
我有一个元素,它的整个内容可以被嵌入。嵌入是可选的,所以我可以让它的内部部分保留,但内部元素被嵌入。让我们看看它的实际效果: Are you sure you want to rem
问题的JsFiddle:http://jsfiddle.net/UYf7U/ 在指令编译中使用 angularJs transclude 时,它将复制任何 属性属性。 IE。 my link 会变
我有一个 Angular 指令,可以从 创建 Accordion 。和 元素,每个 的内容被包裹在一个嵌入的模板中。我需要启动一个方法来检查是否有这些 元素有一个错误,并打开那个 Accordion
我正在学习 AngularJS。 我经历了这个video ,这里显示将 ng-transclude 放在指令模板中的标签上,将在该标签中附加已经存在的 DOM 内容。 代码:
我想知道,是否可以将 $index 参数传递到 ng-transclude 中?我试图通过单击 ng-transclude 中的元素来关注文本区域,触发 Controller 内部的一个函数来查看文本
在我的 Angular 应用程序中,我有几个具有共享结构、相同 html 的面板。 面板内部的内容和行为发生变化,基本上每一个都是一个单独的指令,我们称它们为面板内容。 这是我认为最接近的解决方案,但
我正在尝试添加一个包含左面板和右面板的正文指令。但在这些面板之间,我会有一些 body 指令私有(private)的内容。我目前正在使用 嵌入=真 加载内容的选项。但是,我正在寻找一种使用两个 ng-
我想使用指令,转入内容,并在转入部分中调用指令的 Controller 方法: click me app.directive "mydirective", -> retur
我正在编写两个指令来包装 ui-bootstrap 的 tabset 和 tab 指令。 为了将我的指令的内容传递给包装的指令,我在它们中都使用了嵌入。 这很好用,唯一的问题是我没有编写一个检查它的测
我想在第一次将被嵌入元素插入到具有隔离作用域的指令中的标记中时访问它的作用域。我可以使用 transclude 函数访问被嵌入元素的克隆,但不是第一次插入元素。 我有以下 HTML 我有两
我是一名优秀的程序员,十分优秀!