NG to TiNG Journey – Johan Compagner
Servoy engineer, Johan Compager, talks about the journey going from NG to TiNG (Titanium/NG2).
NG Client
- NG client was created to improve the UI of Smart Client by decoupling the implementation of components from the UI.
- Angular was chosen as the framework for NG client due to its popularity and compatibility with the existing Smart Client architecture.
- Prototyping for NG client began in 2014, but the release of Angular 2 prompted a significant rewrite of the codebase.
NG Titanium
- The key difference between NG client and Titanium is that Titanium's code is compiled upfront, whereas NG client's code was compiled in the browser.
- Titanium uses Angular and comes with TypeScript, making it similar to Angular 1.
- Titanium is moving away from MVC into a pure class-based structure for better inheritance.
- Custom components should not use jQuery as modern browsers are fast enough to handle most tasks.
- Two-way data binding in Titanium is different from Angular 1, with data flow being top-down and components needing to emit value changes.
Angular 9
- Angular 9 uses a build-time compiler, which generates JavaScript code and templates that are pushed to the server.
- Angular 9 no longer supports the table view component, but it includes an Angular grid based on AG Grid.
- CSP protection has been enhanced to prevent HTML with JavaScript hard links back to the system.
- Some styling changes have been made to the components.
- Some components and features from Angular 1 are no longer supported in Angular 9, such as Google charts.
Conversion Process
- The template conversion process involves taking the Angular 1 template and making necessary changes to convert it to Titanium syntax.
- The binding process is similar between Angular 1 and Titanium, with some minor differences in syntax.
Angular Best Practices
- The video discusses how to properly handle class changes in Angular components to optimize performance.
- It explains that the previous approach of using
[ngClass](0daa534f-7f35-4e3f-a9f8-5b17ddff3fb6)
with an array of classes can lead to unnecessary change detection and performance issues, especially when there are many components on the screen.
- The recommended approach is to use the
[ngClass]
directive with a single string of classes, which is more efficient and avoids constant array creation and change detection.
- The video also mentions the importance of using
OnPush
change detection strategy to minimize unnecessary change detection cycles.
- It highlights the difference between
[(ngModel)]
and[ngModel]
, where the former sets the value and executes transformers and formatters, while the latter pushes the value and emits events back to the system.
- The video explains that Angular 2+ no longer has automatic watches like Angular 1, and components now need to explicitly handle value changes and emit events to update the model.
- It also mentions that model properties are no longer directly accessible in the template and should be exposed as inputs to the component.
- The video emphasizes the importance of following Angular component best practices and using inputs and outputs for proper data flow and event handling.
Converting AngularJS 1 to Angular 2
- The speaker discusses the process of converting AngularJS 1 components to Angular 2 components.
- They mention that design-time properties cannot be set at runtime and should be checked only once in the
init
method.
- Extending the base component and calling
super
is recommended to ensure proper functionality.
- The speaker highlights that the server-side code is similar in both AngularJS 1 and Angular 2 clients.
- They emphasize the importance of learning by example and recommend using simpler components as references.
- The speaker mentions that the
Block UI
service has a few methods specific to Angular 2.
- They suggest using services for cleaner code organization and explain the advantages of using getters and setters.
Q&A
- The speaker is tired of answering questions.
- They have been answering questions for a long time.
- They are willing to answer more questions, but not on camera.
- They hope that the audience did not fall asleep during the Q&A.
- One audience member asks when they will do a session that they can also understand.
- The speaker does not want to use the word "tricky" to describe the question.