Angular/CLI stories

1. From: https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/proxy.md
We create a file next to projects package.json called proxy.conf.json with the content
{
  "/api": {
    "target": "http://localhost:3000",
    "secure": false
  }
}
You can read more about what options are available here webpack-dev-server proxy settings
and then we edit the package.json file's start script to be
"start": "ng serve --proxy-config proxy.conf.json",
now run it with npm start
 
Ref: https://webpack.github.io/docs/webpack-dev-server.html#proxy 
// Multiple entry
proxy: [
  {
    context: ['/api-v1/**', '/api-v2/**'],
    target: 'https://other-server.example.com',
    secure: false
  }
] 
 

import {Http} from '@anuglar/http';
import 'rxjs/Rx'

data:any;
ngOnInit(){
 this.http.get('api/getSrc').map
  (res=> res.json()).subscribe
  (data=>{this.data=data;})
}

in package.json
"scripts":{
  "start":"ng serve --proxy-config proxy.conf.json",
 "build":"ng build --prod --bh /test2/"
},
>npm start 
 
2. In angular-cli.json
"apps":[
 {...
 "assets":["assets","favicon.ico","imgs"],  // build out assets into the target package.
...
] 
>npm run build

>ng build --deploy-url /hotest/a1/ --base-href /hotest/a1/ -aot -prod 
 
 

评论

此博客中的热门博文

XML, XSL, HTML

Input in element.eleme.io

Data URI是由RFC 2397 ACE