Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<undefined> html tag getting generated in angular2 beta 0 app

I am currently using the latest angular.beta.0 and have followed their quick start tutorial with the router tutorial. The app works fine but upon inspecting the generated DOM, there is an <undefined> tag generated. It isnt causing any issues but I would want it to be clarified.

The undefined tag contains the whole app markup in it.

enter image description here

like image 397
codin Avatar asked Dec 17 '15 09:12

codin


1 Answers

When Routing you can skip the selector in the components, which is valid. But they will appear as undefined. That may look ugly, so you can avoid it by specifying a selector which will work as a name and won't match any custom element in your templates.

So this will produce an undefined custom element in your DOM

// Some component loaded through routing    
@Component({
    // No selector!
    template : 'Some template'
})

This will not

// Some component loaded through routing    
@Component({
    selector : 'some-component',
    template : 'Some template'
})

This case will show some-component in the DOM instead of undefined.

I hope it helps.

like image 93
Eric Martinez Avatar answered Oct 28 '22 23:10

Eric Martinez