現今三大主流 Angular, Vue, React 當中,為何選 Angular?
讓我們休息一會兒,聽個故事
回到正題,Angular 一個完整的平台,不是單純的框架或 javascript 套件
開發 Angular 需要什麼?
Angular 透過獨立編譯,使得程式不再相依於瀏覽器
Component 架構
深入 W3C 規範
<tabs>
<tab title="About">
<h1>This is the about tab</h1>
</tab>
<tab title="Profile">
<h2>This is the profile tab</h2>
</tab>
<tab title="Contact Us">
<form>
<textarea name="message"></textarea>
<input type="submit" value="Send">
</tab>
</tabs>
import { Component } from '@angular/core'
import { AccountService } from '../services/account.service'
現代 javascript 語法
Classes
Decorators
Modules
Template Literals
以下舉一個範例,說明上述提到的四大項
import { Component } from '@angular/core'
@Component ({
selector: 'my-component',
template:`
<div>
<h4>{{title}}</h4>
</div>
`
})
export class MyComponent {
constructor() {
this.title = 'My Component'
}
}
Observables
this.http.get('/api/user').subscribe(user= > {
// Do something with the record
},
(error) => {
// Handle the error
});
Typescript and Angular
以上就是本篇對 Angular 一個草草的介紹,相信大家已經迫不及待想寫了,那就繼續往下看吧!
我也蠻喜歡 Angular 的一點是每次要升級時,幾乎不用變化到太多程式碼,還有蠻一目了然的指南可以看!
而且在今年的 MDN 上也可以找到 Angular 的基礎教學,據說這份文件也是 Google 團隊去貢獻的,而且已有一群熱心的開發者翻譯出繁體中文版本可以看哦!
雖然在整個前端框架的生態中,Angular 或許沒有 React、Vue 那麼熱門,但未來還不知道呢