Wednesday, January 25, 2017

Relative paths with module Id in angular 2


We can specify absolute path directly in angular 2 as shown below


import {Component, OnInit} from '@angular/core';
//Import interface
import {IProduct} from './product';
//view for the component
@Component({
    selector:'pm-products',
    templateUrl:'app/products/product-list.component.html',
    styleUrls: ['app/products/product-list.component.css']

})

There are several downsides of using absolute path.
  • Harder to adjust folder structure.
  • Reuse the components
  • Some tools within angular require relative path


Solution

We can use the relative path approach by using moduleId


ModuleId



No comments:

Post a Comment