简体   繁体   中英

<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.

在此输入图像描述

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM