【问题标题】:How to hide Angular component inside AngularJS code如何在 AngularJS 代码中隐藏 Angular 组件
【发布时间】:2021-01-05 22:53:55
【问题描述】:

我有 MyTableComponent AngularJS 代码渲染的 Angular 组件:

// AngularJS code
// src/template/expanded-table.html
   ...
   <div class="table-view-port">
      <my-table ng-show="false" [model]="tableModel"
                                [dataSource]="data">
      </my-table>
   </div>
   ...

在 Angular MyTableComponent 我有:

// Angular code
// shared/components/table/table.component.ts

...
export class MyTableComponent<T> implements OnInit {
    ...
    ngOnInit() {
        console.log('Table component');
    }
    ...

我需要做的只是渲染my-table。我尝试使用ng-show="false" 来做到这一点,但它不起作用。我也试过*ngIf="false",但结果相同。

如果它会以某种方式影响我的降级模块:

// appModule/app.module.downgrade.ts 

const APP_MODULE_DOWNGRADABLES: Mapper[] = [
    ...
    {
        downgradeAs: 'directive',
        entity: {
            component: MyTableComponent
        },
        targetName: 'myTable'
    },
    ...

【问题讨论】:

    标签: javascript angularjs angular


    【解决方案1】:

    ng-show 是一个 angularJs 指令,它呈现一个 html 元素,然后 隐藏 如果条件不明确,*ngIf 是一个 Angular 指令,如果你不想渲染元素,你应该使用ng-if="false",这是正确的angularJs语法。

    documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-12
      • 1970-01-01
      • 2020-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多