【问题标题】:Using AutoForm with Angular Meteor将 AutoForm 与 A​​ngular Meteor 一起使用
【发布时间】:2016-03-30 13:02:15
【问题描述】:

我不熟悉将 Angular 与 Meteor 结合使用(使用 angular-with-blaze),并且之前已将 AutoForm 与 Blaze 结合使用。

创建type="update"的autoForm时,必须传入一个对象作为doc参数

{{#autoForm collection="Fruits" id="updateFruit" type="update" doc=fruit}}
    ...
{{/autoForm}}

问题:如何将文档fruit 传递给autoForm 助手?我应该使用 Angular 控制器还是 Blaze 模板助手?

我也在用ui.router

$stateProvider
    .state('editFruit', {
        url: '/editFruit/:fruit_id',
        templateUrl: 'client/fruits/views/edit-fruit.ng.html'
    })

更新

尝试使用 Blaze 的模板助手,但它似乎没有将对象传递给 Blaze 模板。也许这个功能没有实现,或者我的代码不正确。

Template.updateFruitForm.helpers({
    fruit: function () {
        var href = window.location.href ;
        var fruit_id = href.substr(href.lastIndexOf('/') + 1);
        return Fruits.findOne({_id: fruit_id});
    }
});

【问题讨论】:

    标签: angularjs meteor angular-meteor


    【解决方案1】:

    我在这里的指令中写了一个关于向 Blaze 模板发送参数的部分 - http://www.angular-meteor.com/api/1.3.1/blaze-template#passingargumentstoblazetemplate

    基本上你需要:

    1. 创建一个包含您要包含的模板的新 Blaze 模板
    2. 将参数添加到新模板中
    3. 将新模板包含在 blaze-template 中

    【讨论】:

      猜你喜欢
      • 2017-08-20
      • 1970-01-01
      • 1970-01-01
      • 2015-11-25
      • 2020-11-13
      • 2012-10-23
      • 2014-07-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多