Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save okunokentaro/82bda9ef8eb5f1272fe8fa59fa09e623 to your computer and use it in GitHub Desktop.
Save okunokentaro/82bda9ef8eb5f1272fe8fa59fa09e623 to your computer and use it in GitHub Desktop.
Angular 2 alpha版のAPI変更についてメモ
2015/05/13 にQiitaに投稿した記事のアーカイブです
---
151223現在、beta.0がリリースされましたので本稿のサポートは終了します。
---
150721現在、Angular 2.0.0-alpha.31がリリースされています。~~数版前にDeveloper Previewと銘打ったのは何だったのか~~API変更がけっこう多いので、覚えている限りのAPI変更を記しておきます。記憶から抜けているものがあったら下のコメント欄で補足願います。
以下についての変更は煩雑なので追いません。
- 内部API
- エラーハンドリング用API
- alpha.14以前
見出し名が執筆時・記事修正時の最新のAPI名です。
# `@View`
alpha.19より
- [Big rename. Part of #1244 #1285](https://github.com/angular/angular/pull/1285)
- [`bf79337`](https://github.com/angular/angular/commit/bf7933714a884e10124ce43aa27d63791fc37e6a)
旧称: `@Template`
プロパティも改名
```js:旧
@Template({
url: 'my_app.html',
inline: '<p></p>'
})
```
```js:新
@View({
templateUrl: 'my_app.html',
template: '<p></p>'
})
```
## 廃止になったもの
alpha.22より
- [`8faf636`](https://github.com/angular/angular/commit/8faf6364dc344d53c619a1bdfc1ed4d856375f82)
廃止: `@DynamicComponent`
# `@Directive`
- [refactor(compiler): rename decorator directives into directive #1615](https://github.com/angular/angular/pull/1615)
- [Remove concept of Viewport directives? #1536](https://github.com/angular/angular/issues/1536)
- [`f75a50c`](https://github.com/angular/angular/commit/f75a50c1ddb542d3898def5464629c1f13540ee2)
- [`3aac2fe`](https://github.com/angular/angular/commit/3aac2fefd7f93c74abfa5ee58aa0ea8d4840b519)
旧称: `@Decorator`
旧称: `@Viewport`(統合)
```js:旧
@Decorator({
selector: '[house]'
})
@Viewport({
selector: '[house]'
})
```
```js:新
@Directive({
selector: '[house]'
})
```
## `@Directive.properties`
alpha.26より
`properties`がObjectリテラルからArray<string>に変更されるという大規模なBreaking Changeが入ったため注意。
```
Before
@Directive(properties: {
'sameName': 'sameName',
'directiveProp': 'elProp | pipe'
})
After
@Directive(properties: [
'sameName',
'directiveProp: elProp | pipe'
])
```
- https://github.com/angular/angular/issues/2013
- [`d7df853`] (https://github.com/angular/angular/commit/d7df853bde30ffe97045eff649240284ae6ffdf8)
alpha.19より
- [`bf79337`](https://github.com/angular/angular/commit/bf7933714a884e10124ce43aa27d63791fc37e6a#diff-4c0123a05552194ca61867261e4bafd7L70)
旧称: `@Decorator.bind -> @Decorator.properties`
## `@Directive.hostListeners`
alpha.19より
- [`bf79337`](https://github.com/angular/angular/commit/bf7933714a884e10124ce43aa27d63791fc37e6a#diff-4c0123a05552194ca61867261e4bafd7L73)
旧称: `@Decorator.events -> @Decorator.hostListeners`
## `*ng-if`
alpha.24より
- [Compiler should not request setters for @Viewport bindings #1295](https://github.com/angular/angular/issues/1295)
- [Should the best practice be to prefix Component and Directive selectors, but not properties of components. #1598](https://github.com/angular/angular/issues/1598)
- [Issue 1598: All @Directive need to have a prefix #1827](https://github.com/angular/angular/pull/1827)
- [`d310a9c`](https://github.com/angular/angular/commit/d310a9c0b466407ddce0babdf36d7e4c2476cae3#diff-3818fe897c7a5e7d204961e2cf4d7f8dL30)
旧称: `*if`
## `*ng-non-bindable`
alpha.24より
- [`78d3f62`](https://github.com/angular/angular/commit/78d3f62b6a38b00f1ef3dec4c1d31e8ceebdedcb#diff-424613311e4377f93494247b6dfe521aL19)
旧称: `*non-bindable`
## `*ng-switch`
alpha.24より
- [`e9f236b`](https://github.com/angular/angular/commit/e9f236b70f7e6228a16d3d93bb1ab225c9682978#diff-3eed935d2a641fa803d808d574fa6632L54)
旧称: `*switch`
## `*ng-for`, `ng-for-of`
alpha.24より
- [`111fa60`](https://github.com/angular/angular/commit/111fa60a9352b2ccd064793494def9338b84d537#diff-3037c1b9244afa234b625b5475a8a16bL40)
旧称: `*for`, `of`
# `@Component.appInjector`
alpha.24より
【注意】`hostInjector`, `viewInjector`に分割する準備段階のため`appInjector`は[じきに廃止される可能性あり](https://github.com/angular/angular/commit/7b511462afcd5ea011715d624611ffa4260cec61#commitcomment-11269365)。
- [Merge injectables when creating ElementInjector #2015](https://github.com/angular/angular/issues/2015)
- [Remove ligthDomServices from Directive and shadowDomServices from Component #711](https://github.com/angular/angular/issues/711)
- [refactor(core): renamed injectables into appInjector `7b51146`](https://github.com/angular/angular/commit/7b511462afcd5ea011715d624611ffa4260cec61)
- [chore(services): rename services. `dd3e627`](https://github.com/angular/angular/commit/dd3e6271c259d1fb3e150a4a43bf2f3dac1413e8)
- [chore(rename): rename View and Template concepts for #1244 `bf79337`](https://github.com/angular/angular/commit/bf7933714a884e10124ce43aa27d63791fc37e6a#diff-4c0123a05552194ca61867261e4bafd7L234)
旧称: `@Component.componentServices -> @Component.services -> @Component.injectables`
# ElementRef.nativeElement
alpha.28より
- https://github.com/angular/angular/pull/2712
旧称: `ElementRef.domElement`
---
ほとんど自分用。もしAngular 2に特攻する方がいたら、有るはずのAPIが無い…という時にここでまとめてある! みたいな感じで。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment