- 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 { }
推薦閱讀
- 觸·心:DT時代的大數據精準營銷
- Beginning C++ Game Programming
- 算法零基礎一本通(Python版)
- Visual FoxPro程序設計教程
- Programming ArcGIS 10.1 with Python Cookbook
- aelf區塊鏈應用架構指南
- Linux網絡程序設計:基于龍芯平臺
- 編寫高質量代碼:改善C程序代碼的125個建議
- 游戲程序設計教程
- 網店設計看這本就夠了
- Mastering KnockoutJS
- Learning DHTMLX Suite UI
- 劍指大數據:企業級數據倉庫項目實戰(在線教育版)
- Java網絡編程實戰
- Instant Apache Camel Messaging System