ngIf not working out of the box (Angular Dart)


I created a new project in WebStorm, which produces some sample code. The only modification I’ve made so far is to add an ngIf to the index.html:

<!DOCTYPE html>
   (some boilerplate stuff)

     <div *ngIf="false"> //ALSO TRIED PUTTING THIS IN my-app
       <my-app >Loading...</my-app>

I’m expecting to see an empty web page when I run this, but I actually end up getting the To Do List sample app. Have I missed something really obvious? I’ve reloaded the project but no change.

Below some of the boilerplate sample code (only thing I’ve added here is CORE_DIRECTIVES):


 void main() {  bootstrap(AppComponent);}


selector: 'my-app',
styleUrls: const ['app_component.css'],
templateUrl: 'app_component.html',
directives: const [CORE_DIRECTIVES, materialDirectives, TodoListComponent],
providers: const [materialProviders],
class AppComponent {



Directives and components work only in the template of Angular components.

Outside of component templates, they are just ignored.
You can use dart:html to modify the DOM outside Angular and for example run bootstrap(AppComponent) only after adding <my-app >Loading...</my-app> using dart:html.

Answered By – Günter Zöchbauer

Answer Checked By – Mary Flores (FlutterFixes Volunteer)

Leave a Reply

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