Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find which components are conflicting?

Tags:

angular

I'm using ES5 flavor of Angular 2. And I've encountered this error:

Unhandled Promise rejection: Template parse errors:
More than one component matched on this element.
Make sure that only one component's selector can match a given element.
Conflicting components: class2,class6 ("
    </tbody>
</table>
[ERROR ->]<paging [data]="data" (changed)="loadCountries($event)" unit="country"></paging>
<md-spinner class="lis"): class18@30:0 ; Zone: <root> ; Task: Promise.then ; Value: 

It says class2 and class6. I can't find out the original names of the classes.

Here's my module definition:

var module = ng.core.NgModule({
    imports: [
        ng.platformBrowser.BrowserModule, 
        ng.router.RouterModule.forRoot([].concat([...])), 
        ng.material.MaterialModule, 
        ng.http.HttpModule, 
        ng.common.CommonModule, 
        ng.forms.FormsModule],
    declarations: [
        app.CoalAddWorldCoalSupply, 
        app.FilterValuesDialog, 
        app.CoalFlows, 
        app.ImportWorldCoalSupplies, 
        app.CoalProducts, 
        app.CoalReports, 
        app.CoalUpsertFlow, 
        app.CoalUpsertProduct, 
        app.CoalWorldCoalSupplies, 
        app.CountryList, 
        app.CountryUpsert, 
        app.Dashboard, 
        app.ElectricityHeatGenerations, 
        ...
        ],
    entryComponents: [app.FilterValuesDialog, confirmDialog],
    bootstrap: [app.Layout],
    providers: [globalService]
})
.Class({
    constructor: function () { }
});

document.addEventListener('DOMContentLoaded', function () {
    ng.platformBrowserDynamic
      .platformBrowserDynamic()
      .bootstrapModule(module);
});

Parts specified with ... means more of the same things.

How to understand which class zone.js is referring to?

like image 791
Ali Fallah Avatar asked Jun 16 '17 10:06

Ali Fallah


1 Answers

Let's say we have the following app:

app.component.js

app.AppComponent = Component({
  selector: 'my-app',
  template:
    '<h1>(es5) angular2 4.1.3</h1><comp1></comp1>'
})
.Class({
  constructor: function AppComponent() {}
});

component1.js

app.Component1 = Component({
  selector: 'comp1',
  template:
    'component1'
})
.Class({
  constructor: function Component1() {}
});

component2.js

app.Component2 = Component({
  selector: 'comp1',
  template:
    'component2'
})
.Class({
  constructor: function Component2() {}
});

https://plnkr.co/edit/AKBVbX9ruZM8DchFcfbh?p=preview

So my actions:

enter image description here

like image 169
yurzui Avatar answered Oct 17 '22 20:10

yurzui