meteoric / meteor-ionic

Ionic components for Meteor. No Angular!
http://meteoric.github.io
MIT License
1.51k stars 219 forks source link

Can't override navBar title if template has "title" #311

Open daniel opened 9 years ago

daniel commented 9 years ago

I have a template where I'm trying to set the title in the navbar like this:

  {{#contentFor "headerTitle"}}
    <h1 class="title">Title set in template</h1>
  {{/contentFor}}

But that doesn't work, the title is set to the same as data.title (I use Iron Router and set the data property in the route).

I have no problem on other pages where there is no data.title.

I think it could be a bug caused by this commit: https://github.com/meteoric/meteor-ionic/commit/bbc03d6056a6549ba48ac38eeb6f598441c8c355

jorjordandan commented 9 years ago

Yeah, I think I noticed that as well. I'll submit a PR to fix it.

jorjordandan commented 9 years ago

It's a bit more complicated that I thought. The issue is caused by the commit you mentioned, but when there is data from the router, then there are two contentFor blocks: one in the template, and one in the ionView.

The second contentFor (which turns out to be the one from the ionView template) cancels out the first, and that's why the data always overrides the parameter. To fix this, I need to figure out how to tell if a contentFor block already has any content, so I can create a condition in the ionView template. I don't know how to do that. but I'm working on it...