最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - <undefined> html tag getting generated in angular2 beta 0 app - Stack Overflow

programmeradmin4浏览0评论

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.

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.

Share Improve this question asked Dec 17, 2015 at 9:47 hussainbhussainb 1,2963 gold badges17 silver badges33 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 22

When Routing you can skip the selector in the ponents, 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 ponent loaded through routing    
@Component({
    // No selector!
    template : 'Some template'
})

This will not

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

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

I hope it helps.

发布评论

评论列表(0)

  1. 暂无评论