Souad
Souad

Reputation: 5084

routerlink: ERROR Error: "[object Object]"

I use Angular 6 in my CRUD application, and I have this structure of components:

root: app.component
   - topic.component
     - create-topic.componentI
   - answer.component

I have a button in topic.component that has a routerlink to create-topic component:

<a routerLink="add-topic">
    <button type="button" class="btn btn-primary ">New Topic</button>
</a>

and in the template of topic.component I have this where I want to show the template of create-topic:

<div class="container-fluid">
    <router-outlet></router-outlet>
</div>

This is the configuration of app.routing.module

const routes: Routes = [
    {path: 'add-topic', component: CreateTopicComponent }
]

All other routes I have are working except this one, everytime I click on the button I get this:

ERROR Error: "[object Object]"
resolvePromisehttp://localhost:4200/polyfills.js:5787:31
resolvePromisehttp://localhost:4200/polyfills.js:5744:17
scheduleResolveOrRejecthttp://localhost:4200/polyfills.js:5846:17
invokeTaskhttp://localhost:4200/polyfills.js:5394:17
onInvokeTaskhttp://localhost:4200/vendor.js:58217:24
invokeTaskhttp://localhost:4200/polyfills.js:5393:17
runTaskhttp://localhost:4200/polyfills.js:5161:28
drainMicroTaskQueuehttp://localhost:4200/polyfills.js:5568:25
invokeTaskhttp://localhost:4200/polyfills.js:5473:21
invokeTaskhttp://localhost:4200/polyfills.js:6513:9
globalZoneAwareCallbackhttp://localhost:4200/polyfills.js:6539:17

I don't know where to look and what this error means ? What am I missing? I can't find any other stackoverflow question that is similar to my issue.

Upvotes: 0

Views: 1791

Answers (2)

Exterminator
Exterminator

Reputation: 1246

check the screenshot Router link is given in this way [routerLink]="['/your-path']"

Upvotes: 2

Debasish22
Debasish22

Reputation: 398

Add [routerLink]="['add-topic']" . This should work

Upvotes: 0

Related Questions