1
votes

I am trying to declare a template in my angular-meteor app in a Client javascript file. I have this in my main angular controller which is in the client side.

enter image description here

I am using blaze-template directive to bind blaze template syntax to the angular scope.

In my index.html I have a template as such:

enter image description here

And just below it I have <blaze-template name="rappers"></blaze-template>

However I get an error enter image description here

When I delete my template from the controller javascript file. The error goes away, thus leading me to think my Template call in the javascript side is erroneous. Is there an angular binding issue with the Template ?

As a side note: I did try moving my template to another html file with no luck either

I should probably rephrase or ask another question because the only reason I am trying to use Meteor Templates is so I can use Session.get methods to access my Server side Meteor.methods that access spotify-web-api data. If I can use return Session.get("playlist") in my angular controllers than I'd do it that way. Is there a way to do it the angular way instead of accessing Session data the meteor way of calling Templates like below. ``

Template.tweets.helpers({
    rant: function () {
      return Session.get("tweets");
    }
  })

``
My angular code works with some success but it only console.logs() the data

scope.getElvis = function(){
    Meteor.call('getElvis',function(err,data){
      if(err){
        console.log('failed ', err)
      }
      else{
        console.log('success ', data)
      }
    })
 }
2
Can try moving the Template declaration out of the controller to be global? - Urigo
Hey @Urigo thanks for your response. I have tried moving the Template out of the controller with no success. I should note, I am using meteor's angular package. After some googling, I found that angular@=1.07 utilizes <blaze-template> and your package angular-with-blaze. So I decided to remove angular and install angular-with-blaze. However my app breaks completely. - Felice
Can you share a repo? - Urigo

2 Answers

1
votes

Okay so I solved the issue.

I removed the angular package and installed angular-with-meteor package. I then prefixed my .html file with .ng.html

In my .ng.html file I included my <blaze-template name="list"></blaze-template> In a separate blazetemplate.html file I included my blaze template.

I was unaware that angular package was incapable of rendering blaze templates , so switching over to angular-with-blaze really did the trick.

I feel like documentation does a great job of showing a working example, however doesn't explain in details which packages are capable of blaze templates.

Shout out to Uri and his team at angular-meteor.

Great link to follow if you are stuck. https://github.com/Urigo/angular-meteor/issues/849

0
votes

Remove the existing blaze framework and try following

 meteor add angularui:angular-ui-router

For example you may refer the link below:

http://www.angular-meteor.com/tutorials/socially/angular1/routing-and-multiple-views