0

I am doing angular 4 project and i am new in angular 4. I want to set multiple template in my front website. For Example I have 4 theme in my admin panel and user login and set theme no. 2 for front website so theme no 2 active on his website.

I had an idea that if i can dynamic "templateUrl" so I can do such kind if job but i don't know how to do this.

Example Code:

@Component({
  selector: 'app-products',
  templateUrl: './products.component.html', // dymanic html file
  styleUrls: ['./products.component.css']
})
export class ProductsComponent implements OnInit {

  constructor() { }
  public templateUrl:string;
  ngOnInit() {
    this.templateUrl = './products.component.html';
  }

}

Thanks In Advance.

Ankit
  • 13
  • 5
  • Possible duplicate of [Angular 2/4 component with dynamic template or templateUrl](https://stackoverflow.com/questions/45376628/angular-2-4-component-with-dynamic-template-or-templateurl) – Vikas Jun 24 '18 at 05:59
  • This may help you https://stackoverflow.com/questions/31692416/dynamic-template-urls-in-angular-2 – MANISH KUMAR SINGH Jun 24 '18 at 08:23

1 Answers1

0

your question like this link


My spices : If u want to change the HTML and locations of data and ... etc you will type a new HTML code for each theme,,,

but if you want to change the colors, directions, animation ... etc you will change CSS file ... and you can use LESS or SASS it's description language ... will translated to css and more fixable.

and you can controlling your theme by TS and [ngStyle] on HTML

Rabea AlTaradeh
  • 213
  • 1
  • 9
  • I want to type new html for every theme like wordpress does . my requirement like shopify does. User can choose our theme and can set his store. – Ankit Jun 24 '18 at 09:41