UI路由器:没有视图模板的路由 [英] ui-router: A route with no view template

查看:106
本文介绍了UI路由器:没有视图模板的路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以设置在 UI-路由器的路由只能有一个控制器?其目的是,在一定的网址,我想这样做的唯一事情是采取行动编程,而不是在视图中显示方面东西。我通过阅读文档,但我不知道如果他们提供一种方式来做到这一点。

Is it possible to setup a route in ui-router that only has a controller? The purpose being that at a certain URL, the only thing I'd like to do is take action programatically, and not display anything in terms of a view. I've read through the docs, but I'm not sure if they offer a way to do this.

是的,我已阅读本:<一href=\"https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-open-a-dialogmodal-at-a-certain-state\">https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-open-a-dialogmodal-at-a-certain-state,但事实并非完全是我期待的。

Yes, I have read this: https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-open-a-dialogmodal-at-a-certain-state, but that is not quite what I am looking for.

例如,让我们只说我有一个基本的身体与观点:

For example, let's just say I have a basic body with view:

<body ui-view></body>

和一些基本的配置:

// Routes
$stateProvider
  .state('myaction', {
    url: "/go/myaction",
    onEnter: function() {
      console.log('doing something');
    }
  });

当被访问 /去/ myaction ,视图是空白。是否有可能做到这一点?

When /go/myaction is visited, the view is blank. Is it possible to do this?

推荐答案

我能够通过重定向无头的状态,我正在计划行动,在状态,在无头的状态的结束,以便解决这个问题:

I was able to solve this problem by redirecting the headless state I was taking programmatic action in, to a state WITH a view at the end of the headless state:

$stateProvider
  .state('myaction', {
    url: "/go/myaction",
    onEnter: function() {
      console.log('doing something');
    }
    controller: function($state) {
      $state.go('home');
    }
  });

这篇关于UI路由器:没有视图模板的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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