1

I'm trying to use *ngIf, but i'm only receiving this error:

Can't bind to 'ngIf' since it isn't a known property of 'i'

This is my code:

<div class="animated fadeIn">
    <div class="row">
        <div class="col-xs-12 col-md-12">
            <div class="card">

                <div class="card-header bg-info">
                    Pedidos <i  *ngIf="collapse" class="float-right fa fa-caret-up fa-2x"></i>
                </div>

                <div class="card-body">
                    <table class='table data-table' id='pedidos'>
                    </table>
                </div>

            </div>
        </div>
    </div>
</div>

1 Answer 1

4

You need to ensure that the @NgModule(...) containing this component imports CommonModule

imports: [CommonModule]

otherwise such directives won't be available within that module.

In the AppModule importing BrowserModule includes already CommonModule which makes ngIf and others available for components in AppModule, but other modules must import their dependencies themselves.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.