- Ember.js Cookbook
- Erik Hanchett
- 425字
- 2021-07-16 12:58:00
Creating your first project
In this recipe we'll create our first project.
How to do it...
We'll begin with the Ember CLI tool to create our first project.
- Open the command prompt and type the following command:
$ ember new my-project
This will create a brand new project called
my-project
. The project structure will have everything that we need to get started. - To display this project, we can simply run the server command:
$ cd my-project $ ember server
The
ember server
command will start up a web server on port 4200. You can access this port by openinghttp://localhost:4200
. You should see the default Welcome to Ember website.Tip
It is a good idea to keep the Ember server running while developing your application. Ember CLI uses a tool called LiveReload to refresh the web browser when changes are made. This can be useful to see how new changes are affecting your application. To run LiveReload, simply type
ember server
. This will start the server with LiveReload. - The server command defaults to port 4200. You can easily change this using the
--port
argument:$ ember server --port 1234
This will start the server on port
1234
instead of the default 4200. - Another useful option is the
--proxy
argument. This will proxy all Asynchronous JavaScript and XML (Ajax) requests to the given address. Let's say that we have a node server running on port8080
. We can run the server as follows:$ ember server --proxy http://127.0.0.1:8080
For every Ajax request, Ember now will send these requests to the localhost at port
8080
.Tip
Keep in mind that as of Ember 2.0, Internet Explorer (IE) 8 support has been dropped. All modern web browsers and versions of IE after 8 work fine. If by chance IE 8 support is needed, Ember.js version 1.13 has extended browser support and should work with it.
How it works...
The ember server
command creates a Node.js Express server. This server uses LiveReload and refreshes the web page whenever any changes are made. The server command accepts different arguments, including --proxy
and --port
.
There's more...
When running the server, you have access to tests. After you start the server, you'll have access to the QUnit interface. QUnit is a JavaScript unit testing framework. It is used to run your integration and acceptance tests. To access the interface, navigate your browser to http://localhost:4200/tests
. This will show all your tests in the project. From here, you can see which tests passed and which failed. We will cover this in the later chapters:
- UI圖標創(chuàng)意設(shè)計
- DevOps:軟件架構(gòu)師行動指南
- Mastering Natural Language Processing with Python
- 可解釋機器學習:模型、方法與實踐
- 零基礎(chǔ)學Python網(wǎng)絡(luò)爬蟲案例實戰(zhàn)全流程詳解(入門與提高篇)
- AIRIOT物聯(lián)網(wǎng)平臺開發(fā)框架應用與實戰(zhàn)
- 西門子S7-200 SMART PLC編程從入門到實踐
- Python數(shù)據(jù)可視化之美:專業(yè)圖表繪制指南(全彩)
- Go語言入門經(jīng)典
- AutoCAD基礎(chǔ)教程
- Python編程入門(第3版)
- Learning iOS Penetration Testing
- 程序員的英語
- C/C++程序設(shè)計教程
- Hadoop MapReduce v2 Cookbook(Second Edition)