rendr同构框架触发路由

时间:2015-11-07 02:13:26

标签: isomorphic-javascript rendr

我想在RendrJS中通过javascript触发路由更改。我的用例是用户在def main(): names_in() # This function import the file and read all the content and put the content into a list. print_names(names_in) # Before the names are sorted. names_sorted = sorted(names_in()) # Sort the list of names. for item in names_sorted: print(item) def names_in(): infile = open('names.txt','r') names_list = [] # empty list. names = infile.readline() # read contents. # loop for continue to read. while names != '': names = infile.readline() # continue to the next name. names = names.rstrip('\n') # return a copy of the string which all \n has been stripped from the end of the string. names_list.append(names) # write names in the file into a list. return names_list # return the list back to the function. infile.close() # close the file. def print_names(names_in): # This function will print out the names in the list one per line, single-spaced. for item in names_in(): print(item) main() 页面上,并且在成功注册尝试后,我想将用户定向到/register页面。什么是实现这一目标的最佳方式?

1 个答案:

答案 0 :(得分:1)

Rendr的最佳做法是使用redirectTo,因为它是同构的。

在控制器内部,我们使用:

this.redirectTo('/some/path');

在视图中,我们使用:

this.app.router.redirectTo('/some/path');