0
votes

I'm new to using Angular with Meteor (using angular-with-blaze) and have used AutoForm previously with Blaze.

When creating the autoForm of type="update", an object must be passed in as the doc parameter

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

Question: How can I pass the document fruit to the autoForm helper? Should I be using Angular controllers or Blaze Template Helpers?

I'm also using ui.router:

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

Update

Attempted to use Blaze's template helpers but it does not seem to be passing the object to the Blaze template. Maybe this feature have not been implemented or maybe my code is incorrect.

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

1 Answers

0
votes

I have written a section about sending parameters to Blaze templates inside the directive here - http://www.angular-meteor.com/api/1.3.1/blaze-template#passingargumentstoblazetemplate

Basically you will need to:

  1. Create a new Blaze template that includes the template you want to include
  2. Add the parameters to the new template
  3. Include that new template with blaze-template