Home Angular 4+ : Why isn't ng-if working in app.componet.html?

# Angular 4+ : Why isn't ng-if working in app.componet.html?

user1287
1#
user1287 Published in April 21, 2018, 3:27 pm
 I am currently trying to use an ng-if directive in my app.component.html file: 

This should appear.

This shouldn't, but it does.

 My app.component.ts file looks like this: import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html' }) export class AppComponent { }  I have tried numerous different values instead of 0==1 and it still doesn't work, including using the value of a passed-in variable. It is compiling and displaying without errors, but is not removing the second p. I have also tried *ng-if. When I do that, I get an error: Template parse errors: Can't bind to 'ng-if' since it isn't a known property of 'p'. ("

This should appear.

]*ng-if="0==1">This shouldn't, but it does.

"): ng:///AppModule/AppComponent.html@2:3 Property binding ng-if not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("

This should appear.


 You need to login account before you can post.
Processed in 0.31241 second(s) , Gzip On .