Ember Handlebars Templates in <head> tag

前端 未结 1 929
感动是毒
感动是毒 2021-02-04 20:55

Is it possible for ember (specifically the application template) to operate inside the head tag in order to dynamically change things like the title tag, meta tags, external css

相关标签:
1条回答
  • 2021-02-04 21:29

    In order to make this work, what I did was I created handlebar helpers. For Example, If you want to change the title for views which is very common, here is the helper.

    Ember.Handlebars.helper('headTitle', function(title) {
      Ember.$('head').find('title').text(title);
    }, 'title');
    

    now in any view template you can just add the helper

    {{headTitle 'View Header'}}
    

    Here is the JSbin to check if its working

    0 讨论(0)
提交回复
热议问题