ng-repeat 插入空锚标签 [英] ng-repeat inserting empty anchor tags

查看:16
本文介绍了ng-repeat 插入空锚标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 angular 创建菜单.菜单项可以有子项,需要另一个 ng-repeat 来打印子导航项.尝试在第二个 ng-repeat 中插入锚标记时,我注意到一些奇怪的行为.

I'm trying to create a menu using angular. A menu item can have children requiring another ng-repeat to print the sub nav items. I'm noticing some strange behavior when attempting to insert an anchor tag within the 2nd ng-repeat.

小提琴链接:http://jsfiddle.net/npU7t/

<li ng-repeat="sub_menu_item in menu_item.sub_menu">
    <a href="">
        {{ sub_menu_item.title }}
    </a>
</li>

{
    title: 'menu item with children',
    sub_menu: [
        {
            title: '<-- empty anchor tag???'
        }
    ]
}

结果

<li ng-repeat="sub_menu_item in menu_item.sub_menu" class="ng-scope">
    <a href=""></a>
    <a href="" class="ng-binding"><-- empty anchor tag???</a>
</li>

重复/空锚标记从何而来?如何防止它被创建?

Where the did duplicate / empty anchor tag come from? How can I prevent it from being created?

感谢您的帮助!

推荐答案

这不是 Angular 的错误,而是您如何设置标记.

This isn't a bug with Angular, but rather how you have your markup.

问题实际上是嵌套的 标签,而不是

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆