The goal of this jumpstart app is to provide a simple way to get started with Angular 2 while also showing several key Angular 2 features. The sample relies on System.js to load TypeScript modules and the required scripts used in the application.
Simply clone the project or download and extract the .zip to get started. Here are a few screenshots from the app:
- TypeScript version that relies on classes and modules
- Modules are loaded with System.js
- Defining routes (including child routes)
- Using Custom Components
- Using Custom Directives
- Using Custom Pipes
- Defining Properties and Using Events in Components/Directives
- Using the Http object for Ajax calls along with Rx observables
- Working with Utility and Service classes (such as for sorting and Ajax calls)
- Using Angular 2 databinding Syntax [], () and [()]
- Using Angular forms functionality for capturing and validating data
-
Install Node.js 6.x or higher
-
Run
npm install
to install app dependencies -
Run
npm start
in a separate terminal window to build the TypeScript, watch for changes and launch the web server
(这个会启动一个 RESTful 服务器。)
比如关于 customers,有:
app.get('/api/customers', (req, res) => { ... });
app.get('/api/customers/:id', (req, res) => { ... });
app.post('/api/customers', (req, res) => { ... });
app.put('/api/customers/:id', (req, res) => { ... });
app.delete('/api/customers/:id', function(req, res) { ... });
除了 customers,还有 orders、states,等等:
app.get('/api/orders', function(req, res) {
app.get('/api/states', (req, res) => {
有时候你会发现,nodejs 工具真多!:
// redirect all others to the index (HTML5 history)
app.all('/*', function(req, res) {
// Open browser
var opn = require('opn');
opn('http://localhost:3000').then(() => {
console.log('Browser closed.');
});
- Go to http://localhost:3000 in your browser(其实启动 server 后浏览器会自动打开这个站点。)
Looking for expert onsite Angular 2 training? We've trained the biggest (and smallest :-)) companies around the world for over 15 years. For more information visit http://codewithdan.com.