博文

目前显示的是标签为“angular”的博文

Angular Architecture Summary

图片
summarize this architecture : Anuglar apps contain one or more modules. Every angular application has at least one module which is the root module. Each module contains one or more components and services.A component controls a portion of the view on the browser. Each component contains an HTML template and a class to control the logic for that particular view. The template represents the view in the browser. Module can also have services which contains the business logic of your application. The modules export and import code as when required and finally render the view in the browser. Component Selector : there are three ways to specify the selector. Use it                                   @Component                            HTML as a custom HTML tag      selector: 'app-test',  ...

Request Payload and Anuglar post

Reference:  How to send right format of payload in Angular 2 since the php backend accept only 'x-www-form-urlencoded'? http://stackoverflow.com/questions/38375791/how-to-send-right-format-of-payload-in-angular-2-since-the-php-backend-accept-on import { Http, Response,Headers, RequestOptions} from '@angular/http'; public getUserConfig():Observable<Response>{ let widgetUrl = '/api/getXConfig'; let data =encodeURI('jinData={"USERID":"Jin"}'); let options = new RequestOptions({ withCredentials: true }); var headers = new Headers(); // //headers.append('Content-Type', 'application/json'); //'application/x-www-form-urlencoded') can't send "Request Payload" //headers.append('Content-Type', 'application/x-www-form-urlencoded'); // headers.append('Content-Type', 'text/plain; charset=utf-8'); options.headers=headers; return this._http....

learning angular2

1: Clear Environment   >node –v C:\Users\jchen> del %USERPROFILE%\.npmrc Could Not Find C:\Users\jchen\.npmrc   >rmdir /s/q "c:\Program Files\nodejs" c:\Program Files\nodejs\node_perfctr_provider.man - Access is denied. c:\Program Files\nodejs\npm - Access is denied. c:\Program Files\nodejs\npm.cmd - Access is denied. Access is denied. > rmdir /s/q "%APPDATA%\npm" C:\Users\jchen\AppData\Roaming\npm\NODE_M~1\vs-tac\NODE_M~1\cordova\4300A3~1.0\NODE_M~1\cordova\NODE_M~1\CORDOV~1\NODE_M ~1\CORDOV~1\NODE_M~1\BROWSE~1\NODE_M~1\BROWSE~3\NODE_M~1\COMBIN~1\NODE_M~1\INLINE~1\NODE_M~1 - The directory is not empty. >rmdir /s/q "%APPDATA%\npm-cache" Go Control Panel\All Control Panel Items\Programs and Features uninstall nodejs Manually remove "%APPDATA%\npm" and "%APPDATA%\npm-cache" 2. Install Nodejs Download the file node-v7.7.2-x64.msi from https://nodejs.org/en/dow...

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()).subs...