- 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 { }
推薦閱讀
- Vue 3移動Web開發與性能調優實戰
- Boost程序庫完全開發指南:深入C++”準”標準庫(第5版)
- Oracle 12c中文版數據庫管理、應用與開發實踐教程 (清華電腦學堂)
- Python貝葉斯分析(第2版)
- Kotlin從基礎到實戰
- .NET Standard 2.0 Cookbook
- JavaScript程序設計:基礎·PHP·XML
- App Inventor 2 Essentials
- CodeIgniter Web Application Blueprints
- JavaScript悟道
- Learning Unreal Engine Game Development
- Mastering PowerCLI
- 3ds Max 2018從入門到精通
- Learning IBM Bluemix
- C語言開發寶典