简体   繁体   English

<undefined>在angular2 beta 0 app中生成html标记

[英]<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. 我目前正在使用最新的angular.beta.0,并在路由器教程中遵循了他们的快速入门教程。 The app works fine but upon inspecting the generated DOM, there is an <undefined> tag generated. 该应用程序工作正常,但在检查生成的DOM时,生成了<undefined>标记。 It isnt causing any issues but I would want it to be clarified. 它不会导致任何问题,但我希望它得到澄清。

The undefined tag contains the whole app markup in it. undefined标记包含整个应用程序标记。

在此输入图像描述

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 因此,这将在DOM中生成undefined自定义元素

// 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 . 这种情况将在DOM中显示some-component而不是undefined

I hope it helps. 我希望它有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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