【问题标题】:Setting published app domain and appname in ui-router在 ui-router 中设置已发布的应用程序域和应用程序名称
【发布时间】:2015-08-06 23:48:48
【问题描述】:

我正在使用带有这个 stateProvider 的 angularjs ui-router:

.state("admin", {
           abstract:true,
           url: "/admin",
           templateUrl: "/app/template/adminabstract.html",
           controller: "AdminAbstractController"
       })
         .state("admin.view1", {
             url: "/view1",
             templateUrl: "/app/template/adminview1.html",
             controller: "AdminView1Controller"
         }).state("admin.view2", {
             url: "/view2",
             templateUrl: "/app/template/adminview2.html",
             controller: "AdminView2Controller"
         })

这是当前的本地主机链接:

http://localhost:52058/index.html#/admin/view2

它在 localhost 中工作得很好,但是当我发布到服务器时它不再工作。服务器上的链接如下所示:

http://specific.com/appname/otheridentifier/index.html#/admin/view2

为了让我的应用在发布时能够正常工作,我认为我需要更改我的 ui-router 配置或状态提供程序,以便我的本地主机是

http://localhost:52058/index.html#/appname/otheridentifier/admin/view2

我在正确的轨道上吗?我需要做什么才能完成这项工作?

【问题讨论】:

  • 是您的网站在“specific.org”的根目录或子目录中
  • 它在一个子目录中:

标签: angularjs angular-ui-router


【解决方案1】:

因为你的网站看起来不像它在你不能做的网站根目录

templateUrl: "/app/template/adminview1.html"

/ 表示查看该网站的根目录,因此它查看

http://specific.org/app/template

您希望将模板地址更改为

templateUrl: "/appname/otheridentifier/app/template/adminview1.html"

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-05-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多