Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

参数不固定的子状态bug #37

Closed
ascoders opened this issue Jan 23, 2015 · 5 comments
Closed

参数不固定的子状态bug #37

ascoders opened this issue Jan 23, 2015 · 5 comments

Comments

@ascoders
Copy link

abstract:true,表示不参与匹配,这样他的子集url:'',等于覆盖了其默认值,这样确实可以让任何子集来填充父级的默认状态
但是,不参与匹配,似乎无法获取this.params这种参数
本来父级应该做一些全局操作嘛,获取不到params的话,如果path是带参数的,就不好初始化状态啦。例子:

avalon.state("form.table", {
    controller: "form",
    url: "/{source_type}/{db_name}/{table_name}",
    views: {
      "form_container": {
        templateUrl: '/templates/form/table.html',
      }
    },
    abstract: true,
    onChange: function() {
      console.log(this.params);
    },
});

//sql
  avalon.state("form.table.sql", {
    controller: "table",
    url: "/sql",
    views: {
      "form_table_container": {
        templateUrl: '/templates/form/sql.html',
      }
    },
    onChange: function() {
      console.log('sql');
    },
  });

路由是
/aaa/bbb/ccc
时,this.params能正确输出。
路由是
/aaa/bbb/ccc/sql
这个子状态时,this.params输出为undefined

@gogoyqj
Copy link
Contributor

gogoyqj commented Jan 23, 2015

父子状态之间做一下params共享即可

@ascoders
Copy link
Author

不好做共享~

@gogoyqj
Copy link
Contributor

gogoyqj commented Jan 23, 2015

https://github.com/gogoyqj/mmRouter - 这个里面已经加好了

@ascoders
Copy link
Author

给正美提交个merge请求?

@ascoders
Copy link
Author

#39 改完后出了个新bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants