node.js - <slot> Angular 5 中的功能

标签 node.js angular vue.js

我正在使用 SPA(单页应用程序),我使用 Vue 框架开发应用程序。

  • 前端:Vue
  • 后端:NodeJs

在我的应用程序中,我还有其他用 angular 4 编写的子模块,我想用 angular 编写 Vue 提供的功能。
Here是可以解释 <slot> 的链接功能。

任何人都可以建议在 Angular4 之后实现相同的解决方案吗?

最佳答案

这称为嵌入,通过 Angular 使用 ng-content 实现。

网上看一些教程,比如https://scotch.io/tutorials/angular-2-transclusion-using-ng-content

这允许您创建这样的组件:

@Component({
  selector: 'app-component',
  template: `<div class="container"><ng-content></ng-content></div>`
})
export class AppComponent {}

在您的 HTML 中:

<app-component>Some text</app-component>

将呈现为:

<div class="container">Some text</div>

甚至您也可以命名为 ng-content。如果您有多个内容要替换。例如-

<ng-content select="[card-body]"></ng-content>

关于node.js - <slot> Angular 5 中的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53496627/

相关文章:

javascript - Vue使用输入修改图表

vue.js - vee-validate:是否可以在不更改当前名称的情况下更改 fields-bag-name?

javascript - 3d数组覆盖其他维度的值JS

node.js - 为什么我不能在 OSX 10.8.4 上安装 nodemon 或 supervisor?

css - Vue Material Drawer(如何在 md-content 中显示 file.vue)

angular - Angular 中的 HttpHeaders 设置与附加

Angular CLI 为已经存在的组件创建 .spec 文件

javascript - 如何在 Electron 中正确使用 preload.js

json - 如何从 Node.js 发送 JSON 到 Flash

angular - 'ng build' 将脚本移动到子文件夹