- Expert Angular
- Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
- 111字
- 2021-07-15 17:05:37
Controllers and components in templates
AngularJS provides the ng-controller directive to attach a controller to the view and ties the view to the controller related to that view. Angular doesn't support the controller and the ng-controller directive to associate a controller to the view. The component agrees its associated view or template and not vice versa.
AngularJS:
<div ng-controller="PacktBooksCtrl as vm">
Angular:
@Component({ selector: 'packt-books', templateUrl:'app/packtbooks.component.html' })
In AngularJS, we define controllers using Immediately Invoked Function Expressions (IIFE). In Angular, we define components using TypeScript classes decorated with @Component, providing the metadata such as selector, templateUrl, and others.
AngularJS:
(function () { ... }());
Angular:
@Component({ selector: 'packt-books', templateUrl:'app/packtbooks.component.html' }) export class PacktBooks { }
推薦閱讀
- AngularJS入門與進階
- Flutter開發實戰詳解
- 嵌入式軟件系統測試:基于形式化方法的自動化測試解決方案
- OpenShift開發指南(原書第2版)
- Scratch 3.0少兒編程與邏輯思維訓練
- 名師講壇:Spring實戰開發(Redis+SpringDataJPA+SpringMVC+SpringSecurity)
- LabVIEW虛擬儀器入門與測控應用100例
- HTML5開發精要與實例詳解
- MySQL程序員面試筆試寶典
- Android移動應用開發項目教程
- OpenCV Android Programming By Example
- Application Development with Swift
- Oracle Database XE 11gR2 Jump Start Guide
- Java核心編程
- HTML5 WebSocket權威指南