【问题标题】:How should I declare my namespace for angularJS ui-router so it's valid in html and VS 2013?我应该如何为 angularJS ui-router 声明我的命名空间,以便它在 html 和 VS 2013 中有效?
【发布时间】:2014-06-29 20:35:58
【问题描述】:

在我的 index.html 中,我定义了以下内容:

<html class="dark"
      ng-app="app"
      ng-controller="appController"
      id="ng-app"
      xmlns:ng="http://angularjs.org"
      ng-app="optionalModuleName">

在我的代码中:

 <a ui-sref="home.content({ content: 'overview' })"
    ui-sref-active="current">

据我了解,某些版本的 IE 需要 xmlns:ng="http://angularjs.org 来识别不同的命名空间。

现在我也在使用 ui-router。那么我应该如何声明命名空间呢?

我假设xmlns:ui,但在那之后我应该放什么?

同样在 VS2013 中,它也是无效的。有没有办法告诉 VS2013 忽略它在 HTML 中看到的 ui-?

【问题讨论】:

    标签: asp.net html angularjs visual-studio


    【解决方案1】:

    首先要明确一点-您将索引站点命名为index.html。这让我有点困惑,因为命名空间仅在 xml 文档中使用时才有效。对于html,它将是xml 应用程序xhtml。如果您不知道区别,请在网络上阅读。有很多很好的教程和文章解释了htmlxhtml之间的区别。

    回到你的问题:据我从他们的源代码中可以看出,ui路由器是用有效的angularjs开发的,用法就像使用angular指令一样,所以你应该只包括angularjs命名空间到你的根元素。
    也请阅读以下文档以进一步了解如何使 angularjs 与 Internet Explorer 兼容:https://docs.angularjs.org/guide/ie

    关于你的第二个问题,我不知道你是否可以设置 VS2013 来忽略某些属性,但是从 html5 开始,你可以在它们之前添加 data- 以使其有效 (x)html。
    如此处所述:https://docs.angularjs.org/guide/directive
    在这里:http://www.w3schools.com/tags/att_global_data.asp

    例如:

    <a data-ui-sref="home.content({ content: 'overview' })"
        data-ui-sref-active="current">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-03
      • 2013-01-10
      • 1970-01-01
      • 2012-03-06
      • 1970-01-01
      • 2013-07-18
      • 1970-01-01
      相关资源
      最近更新 更多