You are tasked with creating a dynamic dashboard where users can add or remove widgets based on their preference. Which Angular feature would you leverage to dynamically render these widgets?

  • ngIf structural directive
  • @ViewChild decorator
  • ngOnChanges lifecycle hook
  • ngFor structural directive
To dynamically render widgets based on user preferences, you would leverage the ngIf structural directive in Angular. This directive conditionally renders or removes elements based on a given expression. It's ideal for showing or hiding widgets as needed without re-rendering the entire component. The other options, such as @ViewChild, ngOnChanges, and ngFor, have different use cases and are not suitable for this specific scenario.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *