【问题标题】:How to make custom Pipes in Angular 2/4 with Javascript (no typescript)如何使用 Javascript(无打字稿)在 Angular 2/4 中制作自定义管道
【发布时间】:2017-11-03 00:06:33
【问题描述】:

我想为我的 Angular 4 应用程序制作一个自定义管道,但我找到的所有资源都只显示了如何在 TypeScript 中制作管道。我必须使用 JavaScript。谁能解释一下如何在 JavaScript 中做到这一点?

【问题讨论】:

  • 技术上 typescript 转编译为 javascript

标签: javascript angular angular2-pipe


【解决方案1】:

找到了。来自https://angular.io/docs/ts/latest/cookbook/ts-to-js.html

app.MyPipe = ng.core.Pipe({
  name: 'myPipe'
}).Class({
    constructor: function () {
    }, transform: function (input) {
        return input ? 'Yep' : 'Oh, I don't think so';

    }
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-07
    • 2017-11-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多