Giter Club home page Giter Club logo

Comments (5)

maadc avatar maadc commented on May 28, 2024 1

Hey there,
I got a similar problem. I want to change the component-variable and render a new one in this tag.
When I am initializing the variable with different components it works fine.

Now I got this changeComponent function, but it is not working.

You can find this project in my repo: https://github.com/maadc/wir-app/blob/master/src/app/viewfield/viewfield.component.ts

import { Component} from '@angular/core';
import { LageplanComponent } from './lageplan/lageplan.component';
import { HomeComponent } from './home/home.component';

@Component({
  selector: 'viewfield',
  template: `<ndc-dynamic [ndcDynamicComponent]="component"></ndc-dynamic>`
})

export class ViewfieldComponent {
  component = HomeComponent;

  changeComponent(){
    this.component = LageplanComponent;
  }
}

from ng-dynamic-component.

gund avatar gund commented on May 28, 2024

If your goal is to change component type to render another component that is totally possible you just need to update the variable passed to ndcDynamicComponent input.

But you have to make sure that change detection is triggered in case your parent components are in OnPush mode.

from ng-dynamic-component.

ybrodsky avatar ybrodsky commented on May 28, 2024

I tried doing just that and didn't work.

Could you elaborate a little bit on the change detection, or point me in the right direction? This is literally my 2nd day with Angular

from ng-dynamic-component.

gund avatar gund commented on May 28, 2024

Well if you did not explicitly change your change detection for component then there is not point in worrying about that - it should just work.
If you can provide plunkr of what you trying to do it will be more helpful and I then can better understand and help you achieve what you want.

from ng-dynamic-component.

gund avatar gund commented on May 28, 2024

Closing due to inactivity.

from ng-dynamic-component.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.