Angular note
Angular CLI 實用指令
npm install -g angular-cli 安裝
ng --help 說明
ng new 建立新專案
ng g c 建立component
ng g p 建立pipe
...常用<schematic>:
class component directive enum guard interface module pipe service
ng serve --open 啟用網站
基本內容建立格式
1. Import
2. 修飾詞
3. Output
資料綁定 4種
{{}}
[property] = "value" : 屬性綁定
(event) = "hander" : 事件綁定
[(ngModel)] = "property" : 雙向綁定
<!-- 雙向綁定 -->
<input [(ngModel)]="property">
<!-- 屬性綁定 -->
<input [ngModel]="property">
<!-- 事件綁定 -->
<input (ngModelChange)="handler($event)">
裝飾結構說明
@Component :
@Pipes
@Directive :
結構型Structural Directives:*ngfor,
屬性型Attribute Directives:[(ngModel)]
@Injectable : Service 的裝飾器
Routing說明
forRoot
forChild
路由在查找的時候是有順序性:AppRoutingModule放後面
模組延遲載入 : ex.loadChildren: './feature/feature.module#FeatureModule'
預先載入 :頁面初始化的時候就把所有可延遲載入的模組透過背景非同步地下載
負責重新配置頁面中應該顯示哪些 Component
[routerLink]="['..', path.checkoutFlow.paymentInfo]" 回上層
其他:
Angular JIT vs AOT
Component 只負責處理畫面、資料綁定
Service 則負責像是取得資料、表單驗證等等的邏輯處理,
ref :
[Angular 深入淺出三十天] https://ithelp.ithome.com.tw/articles/10205808
custom pipes https://angular.io/guide/pipes#custom-pipes
[Angular 大師之路] https://ithelp.ithome.com.tw/articles/10203550
[Angular2速成班]用Angular CLI節省你的開發時間 https://dotblogs.com.tw/wellwind/2016/09/30/angular2-angular-cli
HTTP Cache 機制 https://blog.techbridge.cc/2017/06/17/cache-introduction/
好用擴充:
angular2-prettyjson
2019年12月31日 星期二
2019年12月20日 星期五
[C#] 推薦分析程式工具
推薦暗黑大筆記 : 重構筆記 - .NET 壞味道補充包
裡面有NDepend 套件內的依些壞味道rule
一些常見的壞味道
1.一個類別太大 200行以上
2.方法太大太複雜
3.方法參數過多
還有很多值得學習與思考的地方
強烈推薦可以去研究看看
2019年12月19日 星期四
[sql] 將特定欄位當作 column
最近遇到要把 資料庫某個欄位當作 column 使用
所以就查詢了一下,目前有兩種方式
1.使用PIVOT, 轉置table, 但是原始column name 不能跟欄位裡面的值重複, 不然會出錯
說明: 先動態取得要轉置成column的欄位, ColumnGroup , 組成需要的字串, 再用PIVOT轉置TABLE
所以就查詢了一下,目前有兩種方式
1.使用PIVOT, 轉置table, 但是原始column name 不能跟欄位裡面的值重複, 不然會出錯
說明: 先動態取得要轉置成column的欄位, ColumnGroup , 組成需要的字串, 再用PIVOT轉置TABLE
2019年12月13日 星期五
[sql] 撈取所有DB 的 所有TABLE
最近有個需求是直接給一張table, 但卻不知道在眾多DB的哪一個DB裡面
因此股哥到列出所有DB 及其 Table 並整理如下:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--讀取所有db | |
select type, name,quotename(name,''''),state from master.sys.databases | |
--query db table | |
select * FROM [DB].sys.tables | |
select * from [DB].sys.schemas | |
--query dbo table name | |
SELECT 'master' as database_name, | |
s.name COLLATE DATABASE_DEFAULT as schema_name, | |
t.name COLLATE DATABASE_DEFAULT as table_name | |
FROM [master].sys.tables t | |
JOIN [master].sys.schemas s on s.schema_id = t.schema_id | |
--query all db and tables | |
declare @sql nvarchar(max); | |
select @sql = | |
stuff((select ' UNION ALL | |
SELECT ' + + quotename(name,'''') + ' as database_name, | |
s.name COLLATE DATABASE_DEFAULT as schema_name, | |
t.name COLLATE DATABASE_DEFAULT as table_name | |
FROM '+ quotename(name) + '.sys.tables t | |
JOIN '+ quotename(name) + '.sys.schemas s on s.schema_id = t.schema_id' | |
from sys.databases | |
where state=0 | |
order by [name] for xml path(''), type).value('.', 'nvarchar(max)'), 1,12,''); | |
select @sql; | |
set @sql = 'select * from (' + @sql + ') d where table_name = ''queryTableName'' order by database_name, schema_name,table_name'; | |
execute (@sql); | |
訂閱:
文章 (Atom)