简体   繁体   English

将控制器属性传递给Emberjs中的把手助手

[英]Passing Controller Property to Handlebars Helper in Emberjs

I have a property in my controller and i want to pass this property to my custom handlebar helper 我的控制器中有一个属性,我想将此属性传递给我的自定义手柄助手

App.AppController = Ember.Controller.extend({

   json: //this property contain some string
});

and my helper is like this : 我的助手是这样的:

 Handlebars.registerHelper('NGRID', function(json) {
   console.log('im calling in ngrid');
 });

and my view is something like this : 我的观点是这样的:

<script type="text/x-handlebars" data-template-name="table">
     {{!-- Table here --}}
     {{NGRID json}}
</script>

but {{NGRID json}} pass string json to handlebars helper and i need to pass content of json peroperty . {{NGRID json}}将字符串json传递给把手助手,我需要传递json peroperty的内容。

Ember has its own template mechanism. Ember有自己的模板机制。 You need to use registerBoundHelper for passing object 您需要使用registerBoundHelper来传递对象

Ember.Handlebars.registerBoundHelper('NGRID', function(json, options){
    console.log('NGRID json:' + json);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM