【问题标题】:what is the best way to include markdown in angular-meteor在 angular-meteor 中包含降价的最佳方法是什么
【发布时间】:2015-08-09 06:38:30
【问题描述】:

我想在我的模板中包含markdown 文本。 我正在使用angular-meteor,我看到了 2 个替代方案:

  • 安装一个angular包如angular-markdown-directive
  • 包括一个没有.ng.html 后缀的文件,并像这样使用meteor 的降价:{{#markdown}}{{>innerPreview}}{{/markdown}}

还有其他选择吗?它会起作用吗?哪个更好?

【问题讨论】:

    标签: angularjs meteor angular-meteor


    【解决方案1】:

    我在hypercube's package 的大气中创建了包oshai:angular-marked。你可以在大气中搜索它。

    【讨论】:

      【解决方案2】:

      有一次我使用摊牌创建了自己的指令,但后来决定我想摆脱它,只使用 Meteor 已经附带的东西。

      第一件事。我有一个名为meteorTemplates.html 的.html 文件。我只是将我使用的所有流星模板放在这里。我只有 2 个,而且它们很小。

      无论如何。模板如下所示:

      <template name="mdTemplate">
          {{#markdown}}{{md}}{{/markdown}}
      </template>
      

      在我的控制器里面我有:

      $scope.my.markdown = '#Markdown';
      

      根据angular-meteor docs:

      The meteor-include directive holds the Angular scope of the directive as the as Template.currentData of the Meteor template.
      

      所以,Template.currentData == $scope。

      然后在模板助手中,我将像 $scope 一样使用 Template.currentData()。

      Template.mdTemplate.helpers({
          md: function() {
            return Template.currentData().getReactively('my.markdown');
          }
      });
      

      我的 ng.html 文件将如下所示:

      <div id="markdown-preview">
          <meteor-include src="mdTemplate"></meteor-include>
      </div>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-08-05
        • 1970-01-01
        • 2011-06-18
        • 2023-03-11
        • 2018-02-07
        • 1970-01-01
        • 1970-01-01
        • 2013-03-11
        相关资源
        最近更新 更多