วันพฤหัสบดีที่ 24 พฤษภาคม พ.ศ. 2561

ตังอย่าง Install NodeJs+Angular5

###########################################################################
ตัวอย่างการสร้างProject
1.ติดตั้ง Nodejs  โดย https://nodejs.org/en/
ทำการเลือก Download และ Install ตามระบบปฏิบัติการที่ท่านใช้ เช่น Windows:node-v8.11.2-x64.msi
Linux:เปิดTerminal :::::
$ sudo apt-get update
$ sudo apt-get install nodejs
ถ้าต้องการตรวจสอบว่าNodejsติดตั้งสำเร็จ $nodejs -v

# sudo apt-get install npm
ต้องการตรวจสอบ $npm -v ถ้าแสดงVersion ขึ้นมา หมายถึงติดตั้งสำเร็จ



2.ติดตั้งAngular cli เข้าเว็บ https://github.com/angular/angular-cli/wiki
npm install -g @angular/cli
การตรวจสอบติดตั้งสำเร็จ
 $ ng  help

Generating and serving an Angular project via a development server Create and run a new project:
ng new my-project   //Create Project
cd my-project   //เข้าไปที่Folder Projectที่สร้างขึ้น
ng serve   //คือRun Project
ถ้าต้องการยังไม่กำหนด unstall version พิมพ์ ng new Project-name --skip-install  
แล้วไปแก้ Version ที่Package-json
https://www.youtube.com/watch?v=DiS1weP2qKkhttps://www.youtube.com/watch?v=DiS1weP2qKk
Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files. แสดงว่าติดตั้งสำเร็จ
ต่อไป:::::การสร้าง component::::เปิด vscode -> view->outpout เพื่อ เปิดTerminal Create Component 
# ng g component  components/user   
ถ้าไม่ต้องการ ไฟล์ spec.ts  เพิ่ม # ng g component --spec=flase  componets/user  








##########################################################
Install: Project แปะไว้ครับ
node -v

npm -v

npm i -g npm
++++++++++++++++
d:
mkdir project
cd project

npm i -g yo

npm i -g yo typescript

npm i -g generator-express-ts

npm i -g typings

yo express-ts

cd cockpit-api

tsc



npm i -g nodemon

nodemon bin/www

tsc -w

npm i knex --save
npm i mysql --save
npm i cors --save
npm i @types/knex @types/mysql --save-dev
npm i dotenv --save

host = 110.77.137.82
user = dev
pass = ##212224##
db = cockpit

npm install express

npm i
ng new testapp
npm start //port :4200

สร้างเพจ
ng g c profiles --spec false
ng g c userlevel --spec false

ดูไฟล์ app.routing.ts
ดูไฟล์ app.component.html

สร้าง service
ng g s userlevel --spec false

สร้าง directive
ng g m directives

d:
cd project
git clone git@gitlab.com:cockpitubon/cockpit-api.git
cd cockpit-api
npm i
nodemon bin/www ตามชอบ
tsc -w ตามชอบ

d:
cd project
git@gitlab.com:cockpitubon/cockpit-app.git
cd cockpit-app
npm i
npm start

สร้าง directive คนเดียว
ng g c directives/pagexxxxxx --spec false

1. git add .
2. git commit -m "create gagegraph directive"
3. git push -u origin master



ไม่มีความคิดเห็น:

แสดงความคิดเห็น