Using components in an application
Components can be used in applications in a variety of ways. In this recipe, we'll see how to create a component and add it to a template.
How to do it...
To begin, we'll create a simple component that displays student information.
- In a new application, generate a new component:
$ ember g component student-info
All components must have a dash in their names. This will generate the
student-info
component. This stub will be created in theapp/components
andapp/templates/components
folders as well. - Edit the
student-info.js
file in theapp/components
folder. Add a few simple properties:// app/components/student-info.js import Ember from 'ember'; export default Ember.Component.extend({ name: 'Erik', grade: 12, nickName: ...
Get Ember.js Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.