From another template, I can pass arguments to a component, such as:
<MyComponent @arg1="String" />
I know I could also pass another named object from the template's JS file, but I don't mean to ask about this.
My question is, what different data types can be passed in from the template, as a String was in the line above. Can I pass in booleans? What about an array of strings? And any special syntax for doing so?
Could I for example use {{each}} to loop through an array argument? I guess the alternative's would be either to process through JS, or perhaps work with {{yeild}}. Thanks.
You can pass any primitive, object, or function (which I think is everything in JS) and there are good reasons for doing each of these.
Sometimes special helpers are needed to create them:
@obj={{hash name='Zoey')}}
@bll={{true}}
@arr={{array 1 2 3}}
A function would have to come from somewhere else, though there are helpers like ember-simple-set-helper that let you build it in the template
@fnc={{set this.isAwesome true}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.